Class CleanupRegistry<T>
- java.lang.Object
-
- com.google.ar.sceneform.rendering.CleanupRegistry<T>
-
- All Implemented Interfaces:
ResourceHolder
public class CleanupRegistry<T> extends java.lang.Object implements ResourceHolder
Maintains aReferenceQueue
and executes aRunnable
after each object in the queue is garbage collected.
-
-
Constructor Summary
Constructors Constructor Description CleanupRegistry()
CleanupRegistry(java.util.HashSet<com.google.ar.sceneform.rendering.CleanupItem<T>> cleanupItemHashSet, java.lang.ref.ReferenceQueue<T> referenceQueue)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroyAllResources()
Ignores reference count and releases any associated resourceslong
reclaimReleasedResources()
Polls theReferenceQueue
for garbage collected objects and runs the associatedRunnable
void
register(T trackedObject, java.lang.Runnable cleanupCallback)
AddstrackedOBject
to theReferenceQueue
.
-
-
-
Method Detail
-
register
public void register(T trackedObject, java.lang.Runnable cleanupCallback)
AddstrackedOBject
to theReferenceQueue
.- Parameters:
trackedObject
- The target to be tracked.cleanupCallback
- Will be called aftertrackedOBject
is disposed.
-
reclaimReleasedResources
public long reclaimReleasedResources()
Polls theReferenceQueue
for garbage collected objects and runs the associatedRunnable
- Specified by:
reclaimReleasedResources
in interfaceResourceHolder
- Returns:
- count of resources remaining.
-
destroyAllResources
public void destroyAllResources()
Ignores reference count and releases any associated resources- Specified by:
destroyAllResources
in interfaceResourceHolder
-
-