RefCounted

interface RefCounted

An object which is tied to a resource that is reference-counted. Each time an object uses this resource, they acquire a reference (increment the refCount), and when that object stops using it, they release the reference. Once the number of references reaches 0, the object is destroyed.

Any functions or classes which accept a RefCounted will not automatically acquire a reference; this is your responsibility as the caller, but allows you a fine level of control over what objects own what references.

Inheritors

Properties

Link copied to clipboard
abstract val refCount: Long

Functions

Link copied to clipboard
abstract fun acquire(): RefCounted

Adds one to the reference count of this object.

Link copied to clipboard
abstract fun release(): RefCounted

Removes one from the reference count of this object. If the object's reference count drops to 0, it will be freed and be unusable.