Package 

Class RCPointer


  • 
    public final class RCPointer
    
                        

    A reference-counted pointer to a native C++ object.

    Begins with a reference count of 1 upon creation. Call acquire to increment the reference count, and release to decrement it. When the reference count reaches zero, the onDelete callback is invoked to clean up the native resource.

    • Constructor Detail

      • RCPointer

        RCPointer(Long cppPointer, Function1<Long, Unit> onDelete, String label)
        Parameters:
        cppPointer - The native pointer address.
        onDelete - A callback invoked when the reference count reaches zero to clean up the native resource.
        label - A label for the object pointed to, used for logging purposes, e.g.
    • Method Detail

      • acquire

         final Unit acquire(String source)

        Acquires a reference to this pointer.

        Parameters:
        source - A string indicating the source of the acquire call for logging purposes, e.g.
      • release

         final Unit release(String source, String reason)

        Releases a reference to this pointer. When the reference count reaches zero, the onDelete callback is invoked to clean up the native resource.

        Parameters:
        source - A string indicating the source of the release call for logging purposes, e.g.
        reason - An optional reason for the release, for logging purposes.