public final class DoublyLinkedList extends Object
Each instance of this class is a doubly-linked list, in which each item or node is a piece of memory. The first two words of each node contains the forward and backward links. The third word contains the treadmill. The remaining portion is the payload.
The treadmill object itself must not be moved.
Access to the instances may be synchronized depending on the constructor argument.
Modifier and Type | Field and Description |
---|---|
private Address |
head |
private static Offset |
HEADER_SIZE |
private Lock |
lock |
private int |
logGranularity |
private static Offset |
NEXT_OFFSET |
private static Word |
nodeMask |
private static Offset |
PREV_OFFSET |
Constructor and Description |
---|
DoublyLinkedList(int logGranularity,
boolean shared) |
Modifier and Type | Method and Description |
---|---|
void |
add(Address node) |
(package private) void |
gcspyGatherData(AbstractDriver driver)
Gather data for GCSpy
|
Address |
getHead() |
Address |
getNext(Address node) |
static int |
headerSize() |
boolean |
isEmpty() |
boolean |
isMember(Address node)
Return true if a cell is on a given treadmill
|
boolean |
isNode(Address node) |
static Address |
midPayloadToNode(Address payload) |
static Address |
nodeToPayload(Address node) |
Address |
pop() |
void |
remove(Address node) |
void |
show() |
private final int logGranularity
private static final Offset PREV_OFFSET
private static Offset NEXT_OFFSET
private static Offset HEADER_SIZE
public DoublyLinkedList(int logGranularity, boolean shared)
logGranularity
- TODO needs documentationshared
- whether the instance will be shared between threadspublic static int headerSize()
public static Address nodeToPayload(Address node)
public static Address midPayloadToNode(Address payload)
public boolean isEmpty()
public boolean isMember(Address node)
node
- The cell being searched fortrue
if the cell is found on the treadmillpublic void show()
void gcspyGatherData(AbstractDriver driver)
driver
- the GCSpy space driver