mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Refactor MapQuery.putPrefix() method
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user