pub struct ShutdownCoordinator { /* private fields */ }Expand description
A shutdown coordinator for triggering, and optionally waiting for, tasks to shut down.
Callers register a ShutdownHandle, which can be awaited to observe shutdown being triggered, or checked
synchronously via ShutdownHandle::is_triggered. When a handle is dropped, it reports completion back to the
coordinator; this is what allows shutdown_and_wait to block until every outstanding
handle has finished.
Shutdown is triggered either fire-and-forget, via shutdown, or blocking, via
shutdown_and_wait.
§Shutdown on drop
Shutdown is also triggered implicitly on drop if it hasn’t already been triggered, to enforce that shutdown always happens even in exceptional circumstances. Shutdown on drop is fire-and-forget: when the coordinator’s drop logic has executed, there is no guarantee that all outstanding handles have also been dropped.
Implementations§
Source§impl ShutdownCoordinator
impl ShutdownCoordinator
Sourcepub fn register(&mut self) -> ShutdownHandle ⓘ
pub fn register(&mut self) -> ShutdownHandle ⓘ
Registers and returns a new shutdown handle.
Sourcepub fn shutdown(self)
pub fn shutdown(self)
Signals shutdown to all outstanding handles without waiting.
When it is desirable to wait until all outstanding handles have completed (been dropped), use
shutdown_and_wait.
Sourcepub async fn shutdown_and_wait(self)
pub async fn shutdown_and_wait(self)
Signals shutdown to all outstanding handles, waiting until all handles have completed (been dropped).
If there are no outstanding handles, this returns immediately.
Trait Implementations§
Source§impl Default for ShutdownCoordinator
impl Default for ShutdownCoordinator
Source§fn default() -> ShutdownCoordinator
fn default() -> ShutdownCoordinator
Source§impl Drop for ShutdownCoordinator
impl Drop for ShutdownCoordinator
Auto Trait Implementations§
impl Freeze for ShutdownCoordinator
impl RefUnwindSafe for ShutdownCoordinator
impl Send for ShutdownCoordinator
impl Sync for ShutdownCoordinator
impl Unpin for ShutdownCoordinator
impl UnsafeUnpin for ShutdownCoordinator
impl UnwindSafe for ShutdownCoordinator
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<T> Track for T
impl<T> Track for T
§fn track_resources(self, token: ResourceGroupToken) -> Tracked<Self>
fn track_resources(self, token: ResourceGroupToken) -> Tracked<Self>
Tracked wrapper. Read more§fn in_current_resource_group(self) -> Tracked<Self>
fn in_current_resource_group(self) -> Tracked<Self>
Tracked wrapper. Read more