public class
CleanupRegistry
Maintains a ReferenceQueue
and executes a Runnable
after each object in the queue
is garbage collected.
Public Constructors
Public Methods
void |
destroyAllResources()
Ignores reference count and releases any associated resources
|
long |
reclaimReleasedResources()
Polls the
ReferenceQueue for garbage collected objects and runs the associated Runnable |
void |
Inherited Methods
Public Constructors
public CleanupRegistry ()
public CleanupRegistry (HashSet<CleanupItem<T>> cleanupItemHashSet, ReferenceQueue<T> referenceQueue)
Parameters
cleanupItemHashSet | |
---|---|
referenceQueue |
Public Methods
public void destroyAllResources ()
Ignores reference count and releases any associated resources
public long reclaimReleasedResources ()
Polls the ReferenceQueue
for garbage collected objects and runs the associated Runnable
Returns
- count of resources remaining.
public void register (T trackedObject, Runnable cleanupCallback)
Adds trackedOBject
to the ReferenceQueue
.
Parameters
trackedObject | The target to be tracked. |
---|---|
cleanupCallback | Will be called after trackedOBject is disposed.
|