Struct ebri::ref_counted::RefCounted
source · pub struct RefCounted<T> { /* private fields */ }Expand description
RefCounted stores an instance of type T, and a union of a link to the next
Collectible or the reference counter.
Implementations§
source§impl<T> RefCounted<T>
impl<T> RefCounted<T>
sourcepub fn try_add_ref(&self, order: Ordering) -> bool
pub fn try_add_ref(&self, order: Ordering) -> bool
Tries to add a strong reference to the underlying instance.
order must be as strong as Acquire for the caller to correctly validate the newest
state of the pointer.
Returns a mutable reference to the instance if the number of owners is 1.
sourcepub fn get_mut_unique(&mut self) -> &mut T
pub fn get_mut_unique(&mut self) -> &mut T
Returns a mutable reference to the instance if it is uniquely owned.
sourcepub fn drop_ref(&self) -> bool
pub fn drop_ref(&self) -> bool
Drops a strong reference to the underlying instance.
Returns true if it the last reference was dropped.
sourcepub fn ref_cnt(&self) -> &AtomicUsize
pub fn ref_cnt(&self) -> &AtomicUsize
Returns a reference to its reference count.
sourcepub fn as_collectible(&self) -> &dyn Collectible
pub fn as_collectible(&self) -> &dyn Collectible
Returns a dyn Collectible reference to self.
Trait Implementations§
source§impl<T> Collectible for RefCounted<T>
impl<T> Collectible for RefCounted<T>
source§fn next_ptr_mut(&mut self) -> &mut Option<NonNull<dyn Collectible>>
fn next_ptr_mut(&mut self) -> &mut Option<NonNull<dyn Collectible>>
Returns a mutable reference to the next
Collectible pointer.source§fn drop_and_dealloc(&mut self)
fn drop_and_dealloc(&mut self)
Drops itself and frees the memory. Read more
Auto Trait Implementations§
impl<T> !RefUnwindSafe for RefCounted<T>
impl<T> !Send for RefCounted<T>
impl<T> !Sync for RefCounted<T>
impl<T> Unpin for RefCounted<T>where
T: Unpin,
impl<T> !UnwindSafe for RefCounted<T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more