diff --git a/src/main/java/net/openhft/chronicle/hash/impl/stage/iter/HashSegmentIteration.java b/src/main/java/net/openhft/chronicle/hash/impl/stage/iter/HashSegmentIteration.java index 646e2a40d..3c6c74b46 100644 --- a/src/main/java/net/openhft/chronicle/hash/impl/stage/iter/HashSegmentIteration.java +++ b/src/main/java/net/openhft/chronicle/hash/impl/stage/iter/HashSegmentIteration.java @@ -137,6 +137,7 @@ public abstract class HashSegmentIteration> 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> return interrupted; } + public void hookAfterEachIteration() { + } + @Override public void forEachSegmentEntry(Consumer action) { forEachSegmentEntryWhile(e -> { diff --git a/src/main/java/net/openhft/chronicle/map/impl/stage/iter/MapSegmentIteration.java b/src/main/java/net/openhft/chronicle/map/impl/stage/iter/MapSegmentIteration.java index 164f81b64..dfa8391a5 100644 --- a/src/main/java/net/openhft/chronicle/map/impl/stage/iter/MapSegmentIteration.java +++ b/src/main/java/net/openhft/chronicle/map/impl/stage/iter/MapSegmentIteration.java @@ -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 extends HashSegmentIteration> implements MapEntry, IterationContext { @StageRef MapEntryStages entry; + @StageRef WrappedValueInstanceDataHolder wrappedValueInstanceDataHolder; @StageRef WrappedValueInstanceDataHolderAccess wrappedValueInstanceDataHolderAccess; + @Override + public void hookAfterEachIteration() { + wrappedValueInstanceDataHolder.closeValue(); + } + @Override public void doReplaceValue(Data newValue) { checkOnEachPublicOperation.checkOnEachPublicOperation(); @@ -54,15 +56,4 @@ public abstract class MapSegmentIteration extends HashSegmentIteration< public WrappedValueInstanceDataHolderAccess context() { return wrappedValueInstanceDataHolderAccess; } -// -// @Override -// public void recover(List> usedTierIndexesBySegment) { -// for (int visitedSegmentIndex = 0; visitedSegmentIndex < usedTierIndexesBySegment.size(); -// visitedSegmentIndex++) { -// Set intersection = new HashSet<>( -// usedTierIndexesBySegment.get(visitedSegmentIndex)); -// intersection.retainAll(usedTierIndexes); -// if (Collections.dis) -// } -// } }