mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Close wrapped value after each iteration in MapSegmentIteration
This commit is contained in:
@@ -137,6 +137,7 @@ public abstract class HashSegmentIteration<K, E extends HashEntry<K>>
|
||||
break;
|
||||
}
|
||||
} finally {
|
||||
hookAfterEachIteration();
|
||||
// if doReplaceValue() -> relocation() -> alloc() -> nextTier()
|
||||
// was called, restore the tier we were iterating over
|
||||
if (s.tier != currentTier) {
|
||||
@@ -170,6 +171,9 @@ public abstract class HashSegmentIteration<K, E extends HashEntry<K>>
|
||||
return interrupted;
|
||||
}
|
||||
|
||||
public void hookAfterEachIteration() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachSegmentEntry(Consumer<? super E> action) {
|
||||
forEachSegmentEntryWhile(e -> {
|
||||
|
||||
@@ -21,24 +21,26 @@ import net.openhft.chronicle.hash.Data;
|
||||
import net.openhft.chronicle.hash.impl.stage.iter.HashSegmentIteration;
|
||||
import net.openhft.chronicle.map.MapEntry;
|
||||
import net.openhft.chronicle.map.impl.IterationContext;
|
||||
import net.openhft.chronicle.map.impl.stage.data.instance.WrappedValueInstanceDataHolder;
|
||||
import net.openhft.chronicle.map.impl.stage.entry.MapEntryStages;
|
||||
import net.openhft.chronicle.map.impl.stage.map.WrappedValueInstanceDataHolderAccess;
|
||||
import net.openhft.sg.StageRef;
|
||||
import net.openhft.sg.Staged;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Staged
|
||||
public abstract class MapSegmentIteration<K, V, R> extends HashSegmentIteration<K, MapEntry<K, V>>
|
||||
implements MapEntry<K, V>, IterationContext<K, V, R> {
|
||||
|
||||
@StageRef MapEntryStages<K, V> entry;
|
||||
@StageRef WrappedValueInstanceDataHolder<V> wrappedValueInstanceDataHolder;
|
||||
@StageRef WrappedValueInstanceDataHolderAccess<K, V, ?> wrappedValueInstanceDataHolderAccess;
|
||||
|
||||
@Override
|
||||
public void hookAfterEachIteration() {
|
||||
wrappedValueInstanceDataHolder.closeValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doReplaceValue(Data<V> newValue) {
|
||||
checkOnEachPublicOperation.checkOnEachPublicOperation();
|
||||
@@ -54,15 +56,4 @@ public abstract class MapSegmentIteration<K, V, R> extends HashSegmentIteration<
|
||||
public WrappedValueInstanceDataHolderAccess<K, V, ?> context() {
|
||||
return wrappedValueInstanceDataHolderAccess;
|
||||
}
|
||||
//
|
||||
// @Override
|
||||
// public void recover(List<Set<Long>> usedTierIndexesBySegment) {
|
||||
// for (int visitedSegmentIndex = 0; visitedSegmentIndex < usedTierIndexesBySegment.size();
|
||||
// visitedSegmentIndex++) {
|
||||
// Set<Long> intersection = new HashSet<>(
|
||||
// usedTierIndexesBySegment.get(visitedSegmentIndex));
|
||||
// intersection.retainAll(usedTierIndexes);
|
||||
// if (Collections.dis)
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user