pub struct Counter(/* private fields */);
Expand description
Simple counter with ability to notify task on reaching specific number
Counter could be cloned, total count is shared across all clones.
Implementations§
Source§impl Counter
impl Counter
Sourcepub fn get(&self) -> CounterGuard
pub fn get(&self) -> CounterGuard
Get counter guard.
Sourcepub fn set_capacity(&self, cap: usize)
pub fn set_capacity(&self, cap: usize)
Set counter capacity
Sourcepub fn is_available(&self) -> bool
pub fn is_available(&self) -> bool
Check is counter has free capacity.
Sourcepub async fn available(&self)
pub async fn available(&self)
Check if counter is not at capacity. If counter at capacity it registers notification for current task.
Wait untile counter becomes at capacity.
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