pub struct AsyncCloser<S> { /* private fields */ }future only.Expand description
AsyncCloser holds the two things we need to close a thread and wait for it to finish: a chan to tell the thread to shut down, and a WaitGroup with which to wait for it to finish shutting down.
Implementations§
Source§impl<S> AsyncCloser<S>
impl<S> AsyncCloser<S>
Sourcepub fn new(initial: usize) -> Self
pub fn new(initial: usize) -> Self
Constructs a new AsyncCloser, with an initial count on the [WaitGroup].
Sourcepub fn add_running(&self, running: usize)
pub fn add_running(&self, running: usize)
Adds delta to the [WaitGroup].
Sourcepub fn signal(&self)
pub fn signal(&self)
Signals the AsyncCloser::listen signal.
Sourcepub async fn wait(&self)
pub async fn wait(&self)
Waits on the [WaitGroup]. (It waits for the AsyncCloser’s initial value, AsyncCloser::add_running, and AsyncCloser::done
calls to balance out.)
Sourcepub async fn signal_and_wait(&self)
pub async fn signal_and_wait(&self)
Calls AsyncCloser::signal, then AsyncCloser::wait.
Sourcepub fn listen(&self) -> Notify
pub fn listen(&self) -> Notify
Gets signaled when AsyncCloser::signal is called.
Source§impl<S: AsyncSpawner> AsyncCloser<S>
impl<S: AsyncSpawner> AsyncCloser<S>
Sourcepub fn blocking_wait(&self)
pub fn blocking_wait(&self)
Waits on the [WaitGroup]. (It waits for the AsyncCloser’s initial value, AsyncCloser::add_running, and AsyncCloser::done
calls to balance out.)
Sourcepub fn signal_and_wait_detach(&self)
pub fn signal_and_wait_detach(&self)
Like AsyncCloser::signal_and_wait, but spawns and detach the waiting in a new task.