Struct GracefulShutdown
pub struct GracefulShutdown {
requested: Arc<AtomicBool>,
tx: Sender<bool>,
rx: Receiver<bool>,
grace_period: Duration,
}Expand description
Builder and coordinator for graceful shutdown of persistent GPU kernels.
Captures SIGTERM and SIGINT (Ctrl-C), notifies all holders of
ShutdownSignal, waits for a configurable grace period, then
force-terminates.
Fields§
§requested: Arc<AtomicBool>§tx: Sender<bool>§rx: Receiver<bool>§grace_period: DurationImplementations§
§impl GracefulShutdown
impl GracefulShutdown
pub fn new(grace_period: Duration) -> GracefulShutdown
pub fn new(grace_period: Duration) -> GracefulShutdown
Create a new shutdown coordinator with the given grace period.
The grace period determines how long ShutdownGuard::wait will
allow after the signal fires before it returns (allowing the caller
to force-terminate remaining work).
pub fn with_default_grace_period() -> GracefulShutdown
pub fn with_default_grace_period() -> GracefulShutdown
Create a shutdown coordinator with the default grace period (5 seconds).
pub fn grace_period(&self) -> Duration
pub fn grace_period(&self) -> Duration
Get the configured grace period.
pub fn is_shutdown_requested(&self) -> bool
pub fn is_shutdown_requested(&self) -> bool
Check if shutdown has already been requested.
pub fn signal(&self) -> ShutdownSignal
pub fn signal(&self) -> ShutdownSignal
Obtain a ShutdownSignal that can be cloned and distributed to
kernels and background tasks.
pub fn trigger(&self)
pub fn trigger(&self)
Manually trigger shutdown (useful for programmatic shutdown or testing).
pub fn install(self) -> ShutdownGuard
pub fn install(self) -> ShutdownGuard
Install OS signal handlers and return a ShutdownGuard.
The guard spawns a background task that listens for SIGTERM and
SIGINT (Ctrl-C). When a signal is received the shutdown flag is set
and all ShutdownSignal holders are notified.
Call ShutdownGuard::wait to block until the grace period elapses
after a signal (or until all work completes, whichever comes first).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GracefulShutdown
impl !RefUnwindSafe for GracefulShutdown
impl Send for GracefulShutdown
impl Sync for GracefulShutdown
impl Unpin for GracefulShutdown
impl !UnwindSafe for GracefulShutdown
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
§fn deserialize(
&self,
deserializer: &mut D,
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more