public class LongTreeTracker extends Object
Using 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 and Description |
|---|
LongTreeTracker() |
LongTreeTracker(long timage) |
| Modifier and Type | Method and Description |
|---|---|
static String |
diagString(long bitfield) |
long |
getHighestCompleted() |
long |
getImage() |
long |
getLowestCompleted() |
long |
getTotalCompleted() |
boolean |
isCompleted() |
boolean |
isCompleted(long index) |
long |
setCompleted(long index) |
long |
setCompleted(long index,
long image)
Apply an index value between 0 and 31 inclusive.
|
static String |
toBinaryString(long bitfield) |
String |
toString() |
public LongTreeTracker(long timage)
public LongTreeTracker()
public long setCompleted(long index,
long image)
index - a long value between 0 and 31 to mark as completeimage - the long value which serves as the starting state of the bit fieldpublic long setCompleted(long index)
public boolean isCompleted(long index)
public boolean isCompleted()
public long getLowestCompleted()
public long getHighestCompleted()
public long getTotalCompleted()
public static String toBinaryString(long bitfield)
public static String diagString(long bitfield)
public long getImage()
Copyright © 2017. All rights reserved.