Package org.rocksdb

Class AbstractImmutableNativeReference

java.lang.Object
org.rocksdb.AbstractNativeReference
org.rocksdb.AbstractImmutableNativeReference
All Implemented Interfaces:
AutoCloseable
Direct Known Subclasses:
RocksCallbackObject, RocksObject

public abstract class AbstractImmutableNativeReference extends AbstractNativeReference
Offers functionality for implementations of AbstractNativeReference which have an immutable reference to the underlying native C++ object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final AtomicBoolean
    A flag indicating whether the current AbstractNativeReference is responsible to free the underlying C++ object
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    AbstractImmutableNativeReference(boolean owningHandle)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Frees the underlying C++ object
    protected final void
    Releases this AbstractNativeReference from the responsibility of freeing the underlying native C++ object
    protected abstract void
    The helper function of close() which all subclasses of AbstractImmutableNativeReference must implement to release their underlying native C++ objects.
    boolean
    Returns true if we are responsible for freeing the underlying C++ object

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • owningHandle_

      protected final AtomicBoolean owningHandle_
      A flag indicating whether the current AbstractNativeReference is responsible to free the underlying C++ object
  • Constructor Details

    • AbstractImmutableNativeReference

      protected AbstractImmutableNativeReference(boolean owningHandle)
  • Method Details

    • isOwningHandle

      public boolean isOwningHandle()
      Description copied from class: AbstractNativeReference
      Returns true if we are responsible for freeing the underlying C++ object
      Specified by:
      isOwningHandle in class AbstractNativeReference
      Returns:
      true if we are responsible to free the C++ object
    • disOwnNativeHandle

      protected final 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 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: AbstractNativeReference
      Frees the underlying C++ object

      It is strong recommended that the developer calls this after they have finished using the object.

      Note, that once an instance of AbstractNativeReference has been closed, calling any of its functions will lead to undefined behavior.

      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in class AbstractNativeReference
    • disposeInternal

      protected abstract void disposeInternal()
      The helper function of close() which all subclasses of AbstractImmutableNativeReference must implement to release their underlying native C++ objects.