Class LongTreeTracker
- java.lang.Object
-
- io.engineblock.activityimpl.marker.longheap.LongTreeTracker
-
- Direct Known Subclasses:
LongTreeTrackerAtomic
public class LongTreeTracker extends java.lang.ObjectUsing the 64 bit structure of a long as a heap addressed tracker, where the leaf nodes represent marked values and all others are used to consolidate state.
One bit is ignored, the 2s compliment sign, leaving 63 bits: 31 bits for root and path and 32 bits as leaf nodes.
Each time a leaf node is marked as complete, it's sibling is checked for the same. While both are marked, the same process is checked for its parent and its sibling, and so forth
This approach assumes that it is good to lower contention and retries for atomics when there are many threads active against the tracker. It should be benchmarked with simpler methods to see the complexity is worth it.
-
-
Constructor Summary
Constructors Constructor Description LongTreeTracker()LongTreeTracker(long timage)
-
Method Summary
Modifier and Type Method Description static java.lang.StringdiagString(long bitfield)longgetHighestCompleted()longgetImage()longgetLowestCompleted()longgetTotalCompleted()booleanisCompleted()booleanisCompleted(long index)longsetCompleted(long index)longsetCompleted(long index, long image)Apply an index value between 0 and 31 inclusive.static java.lang.StringtoBinaryString(long bitfield)java.lang.StringtoString()
-
-
-
Method Detail
-
setCompleted
public long setCompleted(long index, long image)Apply an index value between 0 and 31 inclusive. Return the accumulator. If all 32 slots of this tracker have been isCycleCompleted, the returned value will have LSB bit 2 set.- Parameters:
index- a long value between 0 and 31 to mark as completeimage- the long value which serves as the starting state of the bit field- Returns:
- the accumulator
-
setCompleted
public long setCompleted(long index)
-
isCompleted
public boolean isCompleted(long index)
-
isCompleted
public boolean isCompleted()
-
getLowestCompleted
public long getLowestCompleted()
- Returns:
- the lowest index isCycleCompleted, or -1 if none were isCycleCompleted
-
getHighestCompleted
public long getHighestCompleted()
- Returns:
- the highest index isCycleCompleted, or -1 if none were isCycleCompleted
-
getTotalCompleted
public long getTotalCompleted()
-
toBinaryString
public static java.lang.String toBinaryString(long bitfield)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
diagString
public static java.lang.String diagString(long bitfield)
-
getImage
public long getImage()
-
-