pub struct CountDownLatch { /* private fields */ }
Expand description
A synchronization primitive that allows one or more tasks to wait until the given counter reaches zero. This is an async port of CountDownLatch in Java.
Implementations§
Source§impl CountDownLatch
impl CountDownLatch
Sourcepub fn new(count: usize) -> CountDownLatch
pub fn new(count: usize) -> CountDownLatch
Creates a new CountDownLatch
with a given count.
Sourcepub fn wait(&self) -> impl Future<Output = ()>
pub fn wait(&self) -> impl Future<Output = ()>
Cause the current task to wait until the counter reaches zero
Sourcepub async fn wait_for(&self, timeout: Duration) -> bool
pub async fn wait_for(&self, timeout: Duration) -> bool
Cause the current task to wait until the counter reaches zero with timeout.
If the specified timeout elapsed false
is returned. Otherwise true
.
Sourcepub async fn count_down(&self)
pub async fn count_down(&self)
Decrement the counter of one unit. If the counter reaches zero all the waiting tasks are released.
Trait Implementations§
Source§impl Clone for CountDownLatch
impl Clone for CountDownLatch
Source§fn clone(&self) -> CountDownLatch
fn clone(&self) -> CountDownLatch
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for CountDownLatch
impl !RefUnwindSafe for CountDownLatch
impl Send for CountDownLatch
impl Sync for CountDownLatch
impl Unpin for CountDownLatch
impl !UnwindSafe for CountDownLatch
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