diff --git a/src/main/java/net/openhft/chronicle/hash/impl/BigSegmentHeader.java b/src/main/java/net/openhft/chronicle/hash/impl/BigSegmentHeader.java index dea20abc4..a770c45d2 100644 --- a/src/main/java/net/openhft/chronicle/hash/impl/BigSegmentHeader.java +++ b/src/main/java/net/openhft/chronicle/hash/impl/BigSegmentHeader.java @@ -22,6 +22,7 @@ import net.openhft.chronicle.algo.bytes.NativeAccess; import net.openhft.chronicle.algo.locks.VanillaReadWriteUpdateWithWaitsLockingStrategy; import net.openhft.chronicle.core.Jvm; import net.openhft.chronicle.core.OS; +import net.openhft.chronicle.core.threads.ThreadHints; import net.openhft.chronicle.hash.locks.InterProcessDeadLockException; import java.util.concurrent.TimeUnit; @@ -192,6 +193,7 @@ public final class BigSegmentHeader implements SegmentHeader { if (LOCK.tryReadLock(A, null, address + LOCK_OFFSET)) return true; checkInterrupted(interruptible); + ThreadHints.onSpinWait(); } while (System.nanoTime() <= end); return false; } @@ -206,6 +208,7 @@ public final class BigSegmentHeader implements SegmentHeader { if (LOCK.tryReadLock(A, null, address + LOCK_OFFSET)) return true; checkInterrupted(interruptible); + ThreadHints.onSpinWait(); long now = System.currentTimeMillis(); if (now != lastTime) { lastTime = now; @@ -277,6 +280,7 @@ public final class BigSegmentHeader implements SegmentHeader { if (LOCK.tryUpdateLock(A, null, address + LOCK_OFFSET)) return true; checkInterrupted(interruptible); + ThreadHints.onSpinWait(); } while (System.nanoTime() <= end); return false; } @@ -291,6 +295,7 @@ public final class BigSegmentHeader implements SegmentHeader { if (LOCK.tryUpdateLock(A, null, address + LOCK_OFFSET)) return true; checkInterrupted(interruptible); + ThreadHints.onSpinWait(); long now = System.currentTimeMillis(); if (now != lastTime) { lastTime = now; @@ -354,6 +359,7 @@ public final class BigSegmentHeader implements SegmentHeader { if (LOCK.tryWriteLockAndDeregisterWait(A, null, address + LOCK_OFFSET)) return true; checkInterrupted(interruptible); + ThreadHints.onSpinWait(); } while (System.nanoTime() <= end); deregisterWait(address); return false; @@ -374,6 +380,7 @@ public final class BigSegmentHeader implements SegmentHeader { if (LOCK.tryWriteLockAndDeregisterWait(A, null, address + LOCK_OFFSET)) return true; checkInterrupted(interruptible); + ThreadHints.onSpinWait(); long now = System.currentTimeMillis(); if (now != lastTime) { lastTime = now; @@ -455,6 +462,7 @@ public final class BigSegmentHeader implements SegmentHeader { if (tryUpgradeUpdateToWriteLockAndDeregisterWait0(address)) return true; checkInterrupted(interruptible); + ThreadHints.onSpinWait(); } while (System.nanoTime() <= end); deregisterWait(address); return false; @@ -475,6 +483,7 @@ public final class BigSegmentHeader implements SegmentHeader { if (tryUpgradeUpdateToWriteLockAndDeregisterWait0(address)) return true; checkInterrupted(interruptible); + ThreadHints.onSpinWait(); long now = System.currentTimeMillis(); if (now != lastTime) { lastTime = now;