Package org.rocksdb
Class AbstractImmutableNativeReference
- java.lang.Object
-
- org.rocksdb.AbstractNativeReference
-
- org.rocksdb.AbstractImmutableNativeReference
-
- All Implemented Interfaces:
java.lang.AutoCloseable
- Direct Known Subclasses:
RocksCallbackObject,RocksObject
public abstract class AbstractImmutableNativeReference extends AbstractNativeReference
Offers functionality for implementations ofAbstractNativeReferencewhich have an immutable reference to the underlying native C++ object
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.concurrent.atomic.AtomicBooleanowningHandle_A flag indicating whether the currentAbstractNativeReferenceis responsible to free the underlying C++ object
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractImmutableNativeReference(boolean owningHandle)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()Frees the underlying C++ objectprotected voiddisOwnNativeHandle()Releases thisAbstractNativeReferencefrom the responsibility of freeing the underlying native C++ objectprotected abstract voiddisposeInternal()The helper function ofAbstractNativeReference.dispose()which all subclasses ofAbstractImmutableNativeReferencemust implement to release their underlying native C++ objects.booleanisOwningHandle()Returns true if we are responsible for freeing the underlying C++ object-
Methods inherited from class org.rocksdb.AbstractNativeReference
dispose, finalize
-
-
-
-
Method Detail
-
isOwningHandle
public boolean isOwningHandle()
Description copied from class:AbstractNativeReferenceReturns true if we are responsible for freeing the underlying C++ object- Specified by:
isOwningHandlein classAbstractNativeReference- Returns:
- true if we are responsible to free the C++ object
- See Also:
AbstractNativeReference.dispose()
-
disOwnNativeHandle
protected final void disOwnNativeHandle()
Releases thisAbstractNativeReferencefrom the responsibility of freeing the underlying native C++ objectThis 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.- See Also:
AbstractNativeReference.dispose()
-
close
public void close()
Description copied from class:AbstractNativeReferenceFrees the underlying C++ objectIt is strong recommended that the developer calls this after they have finished using the object.
Note, that once an instance of
AbstractNativeReferencehas been disposed, calling any of its functions will lead to undefined behavior.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein classAbstractNativeReference
-
disposeInternal
protected abstract void disposeInternal()
The helper function ofAbstractNativeReference.dispose()which all subclasses ofAbstractImmutableNativeReferencemust implement to release their underlying native C++ objects.
-
-