pub struct CountDownLatch { /* private fields */ }
Expand description
A synchronization aid that allows one or more tasks to wait until a set of operations being performed in other tasks completes.
Implementations§
Source§impl CountDownLatch
impl CountDownLatch
Sourcepub async fn count_down(&self)
pub async fn count_down(&self)
Decrements the count of the latch, releasing all waiting tasks if the count reaches zero.
This method is asynchronous and will lock the internal count before decrementing it.
Sourcepub async fn wait(&self)
pub async fn wait(&self)
Waits until the count reaches zero.
This method is asynchronous and will block the current task until the count reaches zero.
Sourcepub async fn wait_timeout(&self, timeout: Duration) -> bool
pub async fn wait_timeout(&self, timeout: Duration) -> bool
Waits until the count reaches zero or the specified timeout elapses.
This method is asynchronous and will block the current task until the count reaches zero or the timeout elapses.
§Arguments
timeout
- The maximum duration to wait for the count to reach zero.
§Returns
true
if the count reached zero before the timeout elapsed, false
otherwise.
Trait Implementations§
Source§impl Clone for CountDownLatch
impl Clone for CountDownLatch
Source§fn clone(&self) -> CountDownLatch
fn clone(&self) -> CountDownLatch
Returns a copy 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