Top Description Fields Constructors Methods
org.graalvm.nativebridge

public abstract Class NativeObjectCleaner<T>

extends WeakReference<T>
Class Inheritance
Known Direct Subclasses
org.graalvm.nativebridge.NativeObject.NativeObjectCleanerImpl
Imports
java.lang.ref.ReferenceQueue, .WeakReference, java.util.HashMap, .Map

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 NativeObjectCleaner#register() is called, or it can be performed explicitly using NativeObjectCleaner#processPendingCleaners().

Field Summary

Modifier and TypeField and Description
private static final ReferenceQueue<Object>
private static final Object
pack-priv final NativeIsolate

Constructor Summary

AccessConstructor and Description
protected
NativeObjectCleaner(T
object the new weak reference will refer to
referent
,
NativeIsolate
the native object isolate
isolate
)

Creates a new NativeObjectCleaner.

Method Summary

Modifier and TypeMethod and Description
private static void
cleanImpl(long isolateThread, NativeObjectCleaner<?> cleaner)

protected abstract void
cleanUp(long
the isolate thread address to call into isolate.
isolateThread
)

At some point after a referent is garbage collected the NativeIsolate is entered and the cleanUp(long) is executed with the isolate thread address parameter.

public static void
processPendingCleaners()

Performs an explicit clean up of enqueued NativeObjectCleaners.

public final NativeObjectCleaner<T>
register()

Registers NativeObjectCleaner for cleanup.

Field Detail

cleanersQueueback to summary
private static final ReferenceQueue<Object> cleanersQueue
INVALID_ISOLATE_THREADback to summary
private static final Object INVALID_ISOLATE_THREAD
isolateback to summary
pack-priv final NativeIsolate isolate

Constructor Detail

NativeObjectCleanerback to summary
protected NativeObjectCleaner(T referent, NativeIsolate isolate)

Creates a new NativeObjectCleaner.

Parameters
referent:T

object the new weak reference will refer to

isolate:NativeIsolate

the native object isolate

Method Detail

cleanImplback to summary
private static void cleanImpl(long isolateThread, NativeObjectCleaner<?> cleaner)
cleanUpback to summary
protected abstract void cleanUp(long isolateThread)

At some point after a referent is garbage collected the NativeIsolate is entered and the cleanUp(long) is executed with the isolate thread address parameter. This method should perform cleanup in the isolate heap.

Parameters
isolateThread:long

the isolate thread address to call into isolate.

processPendingCleanersback to summary
public static void processPendingCleaners()

Performs an explicit clean up of enqueued NativeObjectCleaners.

registerback to summary
public final NativeObjectCleaner<T> register()

Registers NativeObjectCleaner for cleanup.