pub struct RefCounted { /* private fields */ }Expand description
Support for intrusive atomic reference counting.
This supports intrusive atomic reference counting with adoption. This means
that a new object starts life at a reference count of 1 and has to be adopted
by a type (such as a fbl::RefPtr) that begins manipulation of the reference
count. If the reference count ever reaches zero, the object’s lifetime is
over and it should be destroyed (Release() returns true if this is the case).
Implementations§
Source§impl RefCounted
impl RefCounted
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Create a new RefCounted.
In debug builds, the initial count is set to a sentinel value to detect use before adoption. In release builds, it starts at 1.
Sourcepub unsafe fn adopt(&self)
pub unsafe fn adopt(&self)
Transition the object from unadopted to adopted state.
§Safety
The object has not been adopted: its reference count is still in the state
RefCounted::new left it in. Nothing else accesses the reference count during the call.
Sourcepub fn ref_count_debug(&self) -> i32
pub fn ref_count_debug(&self) -> i32
Current ref count. Only to be used for debugging purposes.
Trait Implementations§
Source§impl Debug for RefCounted
impl Debug for RefCounted
Auto Trait Implementations§
impl !Freeze for RefCounted
impl RefUnwindSafe for RefCounted
impl Send for RefCounted
impl Sync for RefCounted
impl Unpin for RefCounted
impl UnsafeUnpin for RefCounted
impl UnwindSafe for RefCounted
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DTwhere
ST: ?Sized,
DT: ?Sized,
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DTwhere
ST: ?Sized,
DT: ?Sized,
§impl<T, U> Into<U> for Twhere
U: From<T>,
impl<T, U> Into<U> for Twhere
U: From<T>,
Source§impl<T> PinInit<T> for T
impl<T> PinInit<T> for T
Source§unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), !>
unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), !>
slot. Read moreSource§fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>where
F: FnOnce(Pin<&mut T>) -> Result<(), E>,
fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>where
F: FnOnce(Pin<&mut T>) -> Result<(), E>,
self then calls the function f with the initialized
value. Read more