pub struct ShutdownRequest { /* private fields */ }Expand description
A standing request from the host that this process shut down.
Hosts deliver this differently – a POSIX signal, a Windows console control event injected on a thread of the OS’s choosing – but both arrive in a context where almost nothing is safe to do. A handler may not allocate, log, take a lock, or join a thread. So neither host runs the caller’s code: each sets one flag, and the caller reads it whenever it is somewhere it can act.
That is why this is a poll rather than a callback. A callback would invite exactly the work the delivery context forbids.
Implementations§
Source§impl ShutdownRequest
impl ShutdownRequest
Sourcepub fn watching(flag: &'static AtomicBool) -> Self
pub fn watching(flag: &'static AtomicBool) -> Self
Build a handle watching a flag the caller already owns.
The host implementations use this to hand out a view of their own static. It is public because a caller that already has a shutdown flag – one set by a supervisor protocol, or by a test – can present it through the same type rather than the loop it feeds needing two shapes of “should I stop”.
'static is not incidental: a handler set by the OS outlives any
scope, so the flag it writes has to as well.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ShutdownRequest
impl RefUnwindSafe for ShutdownRequest
impl Send for ShutdownRequest
impl Sync for ShutdownRequest
impl Unpin for ShutdownRequest
impl UnsafeUnpin for ShutdownRequest
impl UnwindSafe for ShutdownRequest
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> 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