Class FinalizableReferenceQueue
java.lang.Object
jnr.ffi.util.ref.FinalizableReferenceQueue
A reference queue with an associated background thread that dequeues references and invokes
FinalizableReference.finalizeReferent() on them.
Keep a strong reference to this object until all of the associated referents have been
finalized. If this object is garbage collected earlier, the backing thread will not invoke
finalizeReferent() on the remaining references.
- Since:
- 2.0 (imported from Google Collections Library)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classTry to load Finalizer in its own class loader.(package private) static classLoads Finalizer directly using the current class loader.(package private) static interfaceLoads Finalizer.class.(package private) static classTries to load Finalizer from the system class loader. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final Map<FinalizableReferenceQueue, Boolean> private static final Logger(package private) final ReferenceQueue<Object> The actual reference queue that our background thread will poll.private static final MethodReference to Finalizer.startFinalizer().(package private) final booleanWhether or not the background thread started successfully. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidcleanUp()Repeatedly dequeues references from the queue and invokesFinalizableReference.finalizeReferent()on them until the queue is empty.static void(package private) static MethodgetStartFinalizer(Class<?> finalizer) Looks up Finalizer.startFinalizer().private static Class<?> Iterates through the given loaders until it finds one that can load Finalizer.private void
-
Field Details
-
logger
-
FINALIZER_CLASS_NAME
- See Also:
-
startFinalizer
Reference to Finalizer.startFinalizer(). -
finalizerQueues
-
queue
The actual reference queue that our background thread will poll. -
threadStarted
final boolean threadStartedWhether or not the background thread started successfully.
-
-
Constructor Details
-
FinalizableReferenceQueue
public FinalizableReferenceQueue()Constructs a new queue.
-
-
Method Details
-
cleanUp
void cleanUp()Repeatedly dequeues references from the queue and invokesFinalizableReference.finalizeReferent()on them until the queue is empty. This method is a no-op if the background thread was created successfully. -
pollReferenceQueue
private void pollReferenceQueue() -
loadFinalizer
Iterates through the given loaders until it finds one that can load Finalizer.- Returns:
- Finalizer.class
-
getStartFinalizer
-
cleanUpAll
public static void cleanUpAll()
-