Struct relm4::ShutdownReceiver
source · pub struct ShutdownReceiver { /* private fields */ }
Expand description
Listens to shutdown signals and constructs shutdown futures.
Implementations§
source§impl ShutdownReceiver
impl ShutdownReceiver
sourcepub fn register<F>(self, future: F) -> AttachedShutdown<F>
pub fn register<F>(self, future: F) -> AttachedShutdown<F>
Create a future which will be cancelled on shutdown.
sourcepub async fn wait(self)
pub async fn wait(self)
Waits until a shutdown signal is received.
Examples found in repository?
src/channel/shutdown/attached.rs (line 37)
34 35 36 37 38 39 40 41 42 43 44 45
pub async fn wait(self) -> Either<(), Out> {
let Self { receiver, future } = self;
let cancel = receiver.wait();
futures::pin_mut!(cancel);
futures::pin_mut!(future);
match futures::future::select(cancel, future).await {
Either::Left(_) => Either::Left(()),
Either::Right((out, _)) => Either::Right(out),
}
}