Class CleanupReferenceProcessor

java.lang.Object
com.illumon.util.reference.CleanupReferenceProcessor

public class CleanupReferenceProcessor
extends Object
Utility for draining a reference queue of CleanupReferences and invoking their cleanup methods.
  • Constructor Details

  • Method Details

    • getReferenceQueue

      public <RT> ReferenceQueue<RT> getReferenceQueue()

      Get the reference queue for this cleaner.

      On the first call after construction or resetForUnitTests(), this method initializes the instance as a side effect. Initialization entails:

      1. Constructing a ReferenceQueue.
      2. Starting a daemon thread that will drain the reference queue and invoke CleanupReference.cleanup() on any CleanupReference dequeued.
      Returns:
      The ReferenceQueue constructed in the most recent initialization of this CleanupReferenceProcessor instance
    • resetForUnitTests

      @TestUseOnly public final void resetForUnitTests()
      Reset this instance so that the next call to getReferenceQueue() will re-initialize it and provide a new queue. Results in eventual termination of the daemon thread that may have been draining the existing queue.