pub struct CountdownEvent { /* private fields */ }

Implementations§

A countdown event is a special type of ManualResetEvent that makes it easy to wait for a given number of tasks to complete asynchronously, and then carry out some action. A countdown event is first initialized with a count equal to the number of outstanding tasks, and each time a task is completed, CountdownEvent::tick() is called. A call to CountdownEvent::wait() will block until all outstanding tasks have completed and the internal counter reaches 0.

Countdown events are thread-safe and may be wrapped in an Arc to easily share across threads.

Creates a new countdown event with the internal count initialized to count. If a count of zero is specified, the event is immediately set.

Decrements the internal countdown. When the internal countdown reaches zero, the countdown event enters a set state and any outstanding or future calls to Awaitable::wait() will be let through without blocking (until the event is reset).

Resets a countdown event to the specified count. If a count of zero is specified, the event is immediately set.

Get the current internal countdown value.

Trait Implementations§

Waits for the internal countdown of the CountdownEvent to reach zero.

Test if an event is available without blocking, return false immediately if it is not set. Note that this is not the same as calling Awaitable::wait_for() with a Duration of zero, as the calling thread never yields. Read more
Check if the event has been signalled, and if not, block for limit waiting for it to be set. Returns true if the event was originally set or if it was signalled within the specified duration, and false otherwise (if the timeout elapsed without the event becoming set). Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.