Package com.couchbase.client.core.util
Class Jdk8Cleaner
java.lang.Object
com.couchbase.client.core.util.Jdk8Cleaner
Approximates Java 9's
java.lang.ref.Cleaner
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
An object and a cleaning action registered in a Cleaner. -
Method Summary
Modifier and TypeMethodDescriptionstatic Jdk8Cleaner
create
(ThreadFactory factory) Executes the given cleaning action when the object becomes phantom reachable.static void
registerWithOneShotCleaner
(Object obj, Runnable cleanupTask) Creates a new cleaner, and registers the given cleanup action to run when the given object becomes phantom reachable.
-
Method Details
-
create
-
registerWithOneShotCleaner
Creates a new cleaner, and registers the given cleanup action to run when the given object becomes phantom reachable.The cleaner's thread terminates after the given cleanup task is executed.
The cleaning action should generally not be a lambda, since it's easy to accidentally capture a reference to the object, preventing it from ever becoming phantom reachable.
-
register
Executes the given cleaning action when the object becomes phantom reachable.The cleaning action should generally not be a lambda, since it's easy to accidentally capture a reference to the object, preventing it from ever becoming phantom reachable.
-