pub struct Counter { /* private fields */ }
Expand description
Essentially an AtomicUsize that is clonable and whose count is based on the number of copies (and their size). The count is automatically updated on Drop.
If you want a weak reference to the counter that doesn’t affect the count, see:
WeakCounter
.
Implementations§
Source§impl Counter
impl Counter
Sourcepub fn builder() -> CounterBuilder
pub fn builder() -> CounterBuilder
Create a new default CounterBuilder
.
Sourcepub fn downgrade(self) -> WeakCounter
pub fn downgrade(self) -> WeakCounter
Consume self (causing the count to decrease by size
)
and return a weak reference to the count through a WeakCounter
.
Sourcepub fn spawn_downgrade(&self) -> WeakCounter
pub fn spawn_downgrade(&self) -> WeakCounter
Create a new WeakCounter
without consuming self.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Counter
impl RefUnwindSafe for Counter
impl Send for Counter
impl Sync for Counter
impl Unpin for Counter
impl UnwindSafe for Counter
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