Class NativeObjectCleaner<T>
java.lang.Object
java.lang.ref.Reference<T>
java.lang.ref.WeakReference<T>
org.graalvm.nativebridge.NativeObjectCleaner<T>
A weak reference performing a given action when a referent becomes weakly reachable and is
enqueued into reference queue. The class is not active. The reference queue check is performed
anytime a new
register() is called, or it can be performed explicitly
using processPendingCleaners().-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedNativeObjectCleaner(T referent, NativeIsolate isolate) Creates a newNativeObjectCleaner. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidcleanUp(long isolateThread) At some point after areferentis garbage collected theNativeIsolateis entered and thecleanUp(long)is executed with the isolate thread address parameter.static voidPerforms an explicit clean up of enqueuedNativeObjectCleaners.final NativeObjectCleaner<T> register()RegistersNativeObjectCleanerfor cleanup.Methods inherited from class java.lang.ref.Reference
clear, clone, enqueue, get, isEnqueued, reachabilityFence, refersTo
-
Constructor Details
-
NativeObjectCleaner
Creates a newNativeObjectCleaner.- Parameters:
referent- object the new weak reference will refer toisolate- the native object isolate
-
-
Method Details
-
register
RegistersNativeObjectCleanerfor cleanup. -
cleanUp
protected abstract void cleanUp(long isolateThread) At some point after areferentis garbage collected theNativeIsolateis entered and thecleanUp(long)is executed with the isolate thread address parameter. This method should perform cleanup in the isolate heap.- Parameters:
isolateThread- the isolate thread address to call into isolate.
-
processPendingCleaners
public static void processPendingCleaners()Performs an explicit clean up of enqueuedNativeObjectCleaners.
-