public final class FinalizableProcessor extends FinalizableProcessor
TODO can this be a linked list?
Modifier and Type | Field and Description |
---|---|
private static FinalizableProcessor |
finalizableProcessor
The FinalizableProcessor singleton
|
private static double |
GROWTH_FACTOR
Amount to grow the table by when it is filled
|
private static int |
INITIAL_SIZE
Initial size of the reference object table
|
private int |
lastReadyIndex
Last object ready to be finalized
|
private Lock |
lock
Used to ensure mutual exclusion during table manipulation
|
protected int |
maxIndex
Index of the first free slot in the table.
|
private int |
nextReadyIndex
Next object ready to be finalized
|
protected int |
nurseryIndex
Index of first entry created since last collection
|
protected Object[] |
readyForFinalize
The table of ready objects
|
private static boolean |
STRESS
Stress the system?
|
protected AddressArray |
table
The table of candidates
|
Modifier | Constructor and Description |
---|---|
protected |
FinalizableProcessor()
Create a new table.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Object object)
Allocate an entry in the table.
|
static void |
addCandidate(Object object)
Add a finalization candidate.
|
void |
clear()
Clear the contents of the table.
|
int |
count() |
int |
countReady() |
static int |
countReadyForFinalize() |
void |
forward(TraceLocal trace,
boolean nursery)
Iterates over and forward entries in the table.
|
int |
freeReady() |
static Object |
getForFinalize() |
static FinalizableProcessor |
getProcessor() |
Object |
getReady()
Get an object to run finalize().
|
void |
scan(TraceLocal trace,
boolean nursery)
Scan through the list of references.
|
private static final FinalizableProcessor finalizableProcessor
private static final boolean STRESS
private static final int INITIAL_SIZE
private static final double GROWTH_FACTOR
protected volatile AddressArray table
protected volatile Object[] readyForFinalize
protected int nurseryIndex
protected volatile int maxIndex
private volatile int nextReadyIndex
private volatile int lastReadyIndex
protected FinalizableProcessor()
public void add(Object object)
object
- the object to add to the table of candidatespublic void clear()
FinalizableProcessor
clear
in class FinalizableProcessor
public void forward(TraceLocal trace, boolean nursery)
Currently ignores the nursery hint.
TODO parallelise this code?
forward
in class FinalizableProcessor
trace
- The tracenursery
- Is this a nursery collection ?public void scan(TraceLocal trace, boolean nursery)
Depending on the value of nursery
, we will either
scan all references, or just those created since the last scan.
TODO parallelise this code
scan
in class FinalizableProcessor
nursery
- Scan only the newly created referencestrace
- the thread local trace element.public Object getReady()
public int count()
public int countReady()
public int freeReady()
public static FinalizableProcessor getProcessor()
public static void addCandidate(Object object)
object
- The object with a finalizer.public static Object getForFinalize()
public static int countReadyForFinalize()