RCPointer

class RCPointer(cppPointer: Long, val label: String, onDispose: (Long) -> Unit) : 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.

Parameters

cppPointer

The native pointer address.

label

A label for the object pointed to, used for logging purposes, e.g. "Artboard".

onDispose

A callback invoked when the reference count reaches zero to clean up the native resource.

Constructors

Link copied to clipboard
constructor(cppPointer: Long, label: String, onDispose: (Long) -> Unit)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val isDisposed: Boolean

Whether this object has been disposed due to the reference count reaching 0.

Link copied to clipboard
Link copied to clipboard

The native pointer address.

Link copied to clipboard
open override val refCount: Int

The current reference count.

Functions

Link copied to clipboard
open override fun acquire(source: String)

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

Link copied to clipboard
open override fun release(source: String, reason: String)

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