Package io.deephaven.util.reference
Class CleanupReferenceProcessor
java.lang.Object
io.deephaven.util.reference.CleanupReferenceProcessor
Utility for draining a reference queue of
CleanupReference
s and invoking their cleanup methods.-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionCleanupReferenceProcessor
(@NotNull String name, long shutdownCheckDelayMillis, @NotNull CleanupReferenceProcessor.ExceptionHandler exceptionHandler) Construct a newCleanupReferenceProcessor
. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull CleanupReferenceProcessor
<RT> ReferenceQueue<RT>
Get the reference queue for this cleaner.final void
Reset this instance so that the next call togetReferenceQueue()
will re-initialize it and provide a new queue.
-
Constructor Details
-
CleanupReferenceProcessor
public CleanupReferenceProcessor(@NotNull @NotNull String name, long shutdownCheckDelayMillis, @NotNull @NotNull CleanupReferenceProcessor.ExceptionHandler exceptionHandler) Construct a newCleanupReferenceProcessor
.- Parameters:
name
- The name of the processor, used for naming threadsshutdownCheckDelayMillis
- The frequency with which to check for shutdownexceptionHandler
- Callback for exception handling
-
-
Method Details
-
getDefault
-
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:- Constructing a
ReferenceQueue
. - Starting a daemon thread that will drain the reference queue and invoke
CleanupReference.cleanup()
on anyCleanupReference
dequeued.
- Returns:
- The
ReferenceQueue
constructed in the most recent initialization of thisCleanupReferenceProcessor
instance
- Constructing a
-
resetForUnitTests
Reset this instance so that the next call togetReferenceQueue()
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.
-