Refactor MapQuery.putPrefix() method

This commit is contained in:
leventov
2016-02-17 17:14:39 +07:00
parent 3594027fb5
commit 4b58d21953
2 changed files with 8 additions and 8 deletions
@@ -30,7 +30,6 @@ import net.openhft.sg.StageRef;
import net.openhft.sg.Staged;
import static net.openhft.chronicle.hash.impl.stage.query.KeySearch.SearchState.ABSENT;
import static net.openhft.chronicle.hash.impl.stage.query.KeySearch.SearchState.PRESENT;
@Staged
public abstract class HashQuery<K> implements SetEntry<K> {
@@ -70,7 +69,7 @@ public abstract class HashQuery<K> implements SetEntry<K> {
if (s.nestedContextsLockedOnSameSegment &&
s.rootContextLockedOnThisSegment.latestSameThreadSegmentModCount() !=
s.contextModCount) {
if (ks.keySearchInit() && ks.searchState == PRESENT &&
if (ks.keySearchInit() && ks.searchStatePresent() &&
!hashLookupSearch.checkSlotContainsExpectedKeyAndValue(entry.pos)) {
hlp.closeHashLookupPos();
}
@@ -91,13 +91,14 @@ public abstract class MapQuery<K, V, R> extends HashQuery<K>
protected void putPrefix() {
checkOnEachPublicOperation.checkOnEachPublicOperation();
boolean underUpdatedLockIsHeld = !s.innerUpdateLock.isHeldByCurrentThread();
if (underUpdatedLockIsHeld)
if (!s.innerUpdateLock.isHeldByCurrentThread())
s.innerUpdateLock.lock();
boolean searchResultsNotTrusted = underUpdatedLockIsHeld ||
s.nestedContextsLockedOnSameSegment;
if (hlp.hashLookupPosInit() && ks.searchStateAbsent() && searchResultsNotTrusted)
hlp.closeHashLookupPos();
if (s.nestedContextsLockedOnSameSegment &&
s.rootContextLockedOnThisSegment.latestSameThreadSegmentModCount() !=
s.contextModCount) {
if (hlp.hashLookupPosInit() && ks.searchStateAbsent())
hlp.closeHashLookupPos();
}
}
@Override