locks should throw InterruptedException or return when the current thread is interrupted

This commit is contained in:
Rob Austin
2015-01-31 10:44:08 +00:00
parent 9d55d2d173
commit 89cea2282e
2 changed files with 15 additions and 4 deletions
+1 -1
View File
@@ -47,7 +47,7 @@
<dependency>
<groupId>net.openhft</groupId>
<artifactId>lang</artifactId>
<version>6.4.22</version>
<version>6.5.0-SNAPSHOT</version>
</dependency>
<dependency>
@@ -1469,6 +1469,7 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
final DirectBitSet positions = hashLookup.getPositions();
class EntryChecker implements MultiMap.EntryConsumer {
long size = 0;
@Override
public void accept(long key, long value) {
if (positions.isSet(value))
@@ -1527,7 +1528,12 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
@Nullable SegmentState segmentState) {
while (true) {
// final boolean success = segmentHeader.tryRWReadLock(LOCK_OFFSET, lockTimeOutNS);
final boolean success = segmentHeader.tryRWWriteLock(LOCK_OFFSET, lockTimeOutNS);
final boolean success;
try {
success = segmentHeader.tryRWWriteLock(LOCK_OFFSET, lockTimeOutNS);
} catch (InterruptedException e) {
throw new IllegalStateException(e);
}
/*
boolean success = false;
try {
@@ -1563,7 +1569,12 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
SegmentState segmentState, boolean nativeValueClass) {
startWriteLock = System.nanoTime();
while (true) {
final boolean success = segmentHeader.tryRWWriteLock(LOCK_OFFSET, lockTimeOutNS);
final boolean success;
try {
success = segmentHeader.tryRWWriteLock(LOCK_OFFSET, lockTimeOutNS);
} catch (InterruptedException e) {
throw new IllegalStateException(e);
}
/*
boolean success = false;
try {
@@ -1970,7 +1981,7 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
final void freeExtraAllocatedChunks(long pos, int allocatedChunks, Bytes entry) {
int actuallyUsedChunks;
if (!constantlySizedEntry && couldNotDetermineAlignmentBeforeAllocation && // fast path
(actuallyUsedChunks = inChunks(entry.position())) < allocatedChunks) {
(actuallyUsedChunks = inChunks(entry.position())) < allocatedChunks) {
free(pos + actuallyUsedChunks, allocatedChunks - actuallyUsedChunks);
}
}