Class CleanupReferenceProcessor

java.lang.Object
io.deephaven.util.reference.CleanupReferenceProcessor

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

    • CleanupReferenceProcessor

      public CleanupReferenceProcessor(@NotNull @NotNull String name, long shutdownCheckDelayMillis, @NotNull @NotNull CleanupReferenceProcessor.ExceptionHandler exceptionHandler)
      Construct a new CleanupReferenceProcessor.
      Parameters:
      name - The name of the processor, used for naming threads
      shutdownCheckDelayMillis - The frequency with which to check for shutdown
      exceptionHandler - Callback for exception handling
  • 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 the prompt termination of the daemon thread that may have been draining the existing queue.