RefCounted
struct · ferroui-base · v0.5.0
struct RefCounted<T: ?Sized + 'static>
An explicitly counted reference to a shared resource.
Every reference is disposed on its own; the resource is released when the last one is disposed. A reference that is dropped without having been disposed releases its count as well.
References are shared between the UI thread and the render thread: the count is atomic, as in the original.
Members
dispose
fn dispose(self: &Self)
Releases this reference.
item
fn item(self: &Self) -> Arc<T>
The referenced resource. Panics if this reference has been disposed.
clone_ref
fn clone_ref(self: &Self) -> RefCounted<T>
Creates another reference to the resource. Panics if this reference has been disposed.
clone_as
fn clone_as<TResult: ?Sized + 'static>(self: &Self, cast: impl FnOnce(Arc<T>) -> Arc<TResult>) -> RefCounted<TResult>
Creates another reference to the resource, viewed as another type. Panics if this reference has been disposed.
is_alive
fn is_alive(self: &Self) -> bool
Whether this reference has not been disposed.
ref_count
fn ref_count(self: &Self) -> i32
The number of live references to the resource. Panics if this reference has been disposed.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeClassDefaultsBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>AnyErasedDestructorIntoEitherDrop
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.