Package 

Class DittoHandleWrapper

  • All Implemented Interfaces:
    java.io.Closeable , java.lang.AutoCloseable , live.ditto.internal.ffi.DittoHandle

    
    public final class DittoHandleWrapper
     implements Closeable, DittoHandle
                        

    Container for the rust handle to the main Ditto instance that lives behind the FFI layer.

    • Method Summary

      Modifier and Type Method Description
      Unit close() Invokes ditto_free if we have a non-null handle.
      <R extends Any> R with(Function1<SWIGTYPE_p_CDitto, R> ffiUsage) Yields a scope wherein the so obtained "raw" handle is protected from being deällocated right under our feet, even with multiple threads.
      • Methods inherited from class live.ditto.internal.ffi.DittoHandleWrapper

        ifNonNull, withUnwrapped
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • close

         Unit close()

        Invokes ditto_free if we have a non-null handle.

      • with

         <R extends Any> R with(Function1<SWIGTYPE_p_CDitto, R> ffiUsage)

        Yields a scope wherein the so obtained "raw" handle is protected from being deällocated right under our feet, even with multiple threads.

        Note: doing .with { it } achieves the same as the old .handle getter (modulo a very short-lived synchronized(this) critical section) and thus defeats the point of the API: do not let these "raw" FFI resources escape the scope!