Package org.rocksdb

Class AbstractImmutableNativeReference

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.concurrent.atomic.AtomicBoolean owningHandle_
      A flag indicating whether the current AbstractNativeReference is responsible to free the underlying C++ object
    • Field Detail

      • owningHandle_

        protected final java.util.concurrent.atomic.AtomicBoolean owningHandle_
        A flag indicating whether the current AbstractNativeReference is responsible to free the underlying C++ object
    • Constructor Detail

      • AbstractImmutableNativeReference

        protected AbstractImmutableNativeReference​(boolean owningHandle)
    • Method Detail

      • 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 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: 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 disposed, calling any of its functions will lead to undefined behavior.

        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in class AbstractNativeReference
      • disposeInternal

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