public abstract class AbstractImmutableNativeReference extends AbstractNativeReference
AbstractNativeReference which have an immutable reference to the
underlying native C++ object| Modifier and Type | Field and Description |
|---|---|
protected AtomicBoolean |
owningHandle_
A flag indicating whether the current
AbstractNativeReference is
responsible to free the underlying C++ object |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractImmutableNativeReference(boolean owningHandle) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Frees the underlying C++ object
It is strong recommended that the developer calls this after they
have finished using the object.
|
protected void |
disOwnNativeHandle()
Releases this
AbstractNativeReference from the responsibility of
freeing the underlying native C++ object
This will prevent the object from attempting to delete the underlying
native object in its finalizer. |
protected abstract void |
disposeInternal()
The helper function of
AbstractNativeReference.dispose()
which all subclasses of AbstractImmutableNativeReference must
implement to release their underlying native C++ objects. |
boolean |
isOwningHandle()
Returns true if we are responsible for freeing the underlying C++ object
|
dispose, finalizeprotected final AtomicBoolean owningHandle_
AbstractNativeReference is
responsible to free the underlying C++ objectprotected AbstractImmutableNativeReference(boolean owningHandle)
public boolean isOwningHandle()
AbstractNativeReferenceisOwningHandle in class AbstractNativeReferenceAbstractNativeReference.dispose()protected final void disOwnNativeHandle()
AbstractNativeReference from the responsibility of
freeing the underlying native C++ object
This will prevent the object from attempting to delete the underlying native object in its finalizer. This must be used when another object takes over ownership of the native object or both will attempt to delete the underlying object when garbage collected.
When disOwnNativeHandle() is called, dispose() will
subsequently take no action. As a result, incorrect use of this function
may cause a memory leak.
AbstractNativeReference.dispose()public void close()
AbstractNativeReferenceIt is strong recommended that the developer calls this after they have finished using the object.
Note, that once an instance of AbstractNativeReference has been
disposed, calling any of its functions will lead to undefined
behavior.
close in interface AutoCloseableclose in class AbstractNativeReferenceprotected abstract void disposeInternal()
AbstractNativeReference.dispose()
which all subclasses of AbstractImmutableNativeReference must
implement to release their underlying native C++ objects.Copyright © 2021. All rights reserved.