Class ThreadedHousekeeper

  • All Implemented Interfaces:
    Housekeeper

    public class ThreadedHousekeeper
    extends Object
    implements Housekeeper
    Housekeeper that spins up a daemon thread to execute clean ups.
    • Method Detail

      • setLogLeakedReferences

        public void setLogLeakedReferences​(boolean value)
        Description copied from interface: Housekeeper
        Enable/Disable leaked reference logging
        Specified by:
        setLogLeakedReferences in interface Housekeeper
      • emptyQueue

        public void emptyQueue()
        Description copied from interface: Housekeeper
        Ensures the cleanup queue is emptied immediately
        Specified by:
        emptyQueue in interface Housekeeper
      • add

        public <T> Object add​(T referent,
                              Housekeeper.CleanupRunnable cleanup)
        Description copied from interface: Housekeeper
        Associate a cleanup runnable to be run when a referent is only phantom reference-able.
        Specified by:
        add in interface Housekeeper
        Parameters:
        referent - Reference to track
        cleanup - Runnable to run when referent is phantom-ed
        Returns:
        Key object to use when calling remove
      • remove

        public void remove​(Object cleanupKey)
        Description copied from interface: Housekeeper
        Removes cleanup runnable for the given referent
        Specified by:
        remove in interface Housekeeper
        Parameters:
        cleanupKey - Key to reference to stop tracking
      • testCheckCleaned

        public boolean testCheckCleaned​(int referentId)
        Test only
      • testClear

        public void testClear()
        Test only