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 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.
sourcepub fn poll_available(&self, cx: &mut Context<'_>) -> bool
pub fn poll_available(&self, cx: &mut Context<'_>) -> bool
Check if counter is not at capacity. If counter at capacity it registers notification for current task.
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