Use ThreadHints.onSpinWait() in BigSegmentHeader

This commit is contained in:
leventov
2017-03-06 00:10:01 -06:00
parent 05dfdb5c37
commit 3291a43c95
@@ -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;