Class CleanupRegistry<T>

  • All Implemented Interfaces:
    ResourceHolder

    public class CleanupRegistry<T>
    extends java.lang.Object
    implements ResourceHolder
    Maintains a ReferenceQueue and executes a Runnable 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 resources
      long reclaimReleasedResources()
      Polls the ReferenceQueue for garbage collected objects and runs the associated Runnable
      void register​(T trackedObject, java.lang.Runnable cleanupCallback)
      Adds trackedOBject to the ReferenceQueue.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CleanupRegistry

        public CleanupRegistry()
      • CleanupRegistry

        public CleanupRegistry​(java.util.HashSet<com.google.ar.sceneform.rendering.CleanupItem<T>> cleanupItemHashSet,
                               java.lang.ref.ReferenceQueue<T> referenceQueue)
    • Method Detail

      • register

        public void register​(T trackedObject,
                             java.lang.Runnable cleanupCallback)
        Adds trackedOBject to the ReferenceQueue.
        Parameters:
        trackedObject - The target to be tracked.
        cleanupCallback - Will be called after trackedOBject is disposed.
      • reclaimReleasedResources

        public long reclaimReleasedResources()
        Polls the ReferenceQueue for garbage collected objects and runs the associated Runnable
        Specified by:
        reclaimReleasedResources in interface ResourceHolder
        Returns:
        count of resources remaining.
      • destroyAllResources

        public void destroyAllResources()
        Ignores reference count and releases any associated resources
        Specified by:
        destroyAllResources in interface ResourceHolder