Package 

Class RCPointer

  • All Implemented Interfaces:
    app.rive.core.RefCounted

    
    public final class RCPointer
     implements RefCounted
                        

    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 onDispose callback is invoked to clean up the native resource.

    • Constructor Detail

      • RCPointer

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

      • acquire

         Unit acquire(String source)

        Acquire a reference. Must be balanced with a call to release.

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

         Unit release(String source, String reason)

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

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