Package org.rocksdb
Class AbstractImmutableNativeReference
java.lang.Object
org.rocksdb.AbstractNativeReference
org.rocksdb.AbstractImmutableNativeReference
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
RocksCallbackObject,RocksObject
Offers functionality for implementations of
AbstractNativeReference which have an immutable reference to the
underlying native C++ object-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AtomicBooleanA flag indicating whether the currentAbstractNativeReferenceis responsible to free the underlying C++ object -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Frees the underlying C++ objectprotected final voidReleases thisAbstractNativeReferencefrom the responsibility of freeing the underlying native C++ objectprotected abstract voidThe helper function ofclose()which all subclasses ofAbstractImmutableNativeReferencemust implement to release their underlying native C++ objects.booleanReturns true if we are responsible for freeing the underlying C++ object
-
Field Details
-
owningHandle_
A flag indicating whether the currentAbstractNativeReferenceis responsible to free the underlying C++ object
-
-
Constructor Details
-
AbstractImmutableNativeReference
protected AbstractImmutableNativeReference(boolean owningHandle)
-
-
Method Details
-
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
-
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
close(). This must be used when another object takes over ownership of the native object or both will attempt to delete the underlying object when closed.When
disOwnNativeHandle()is called,close()will subsequently take no action. As a result, incorrect use of this function may cause a memory leak. -
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 closed, calling any of its functions will lead to undefined behavior.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein classAbstractNativeReference
-
disposeInternal
protected abstract void disposeInternal()The helper function ofclose()which all subclasses ofAbstractImmutableNativeReferencemust implement to release their underlying native C++ objects.
-