pub struct ShutdownToken { /* private fields */ }Expand description
A clonable shutdown token that tasks can poll or wait on.
Contract: this token is a cooperative cancellation primitive.
Tasks/threads are expected to poll ShutdownToken::is_shutdown and exit promptly when it
becomes true.
Features: waiting APIs require std.
Implementations§
Source§impl ShutdownToken
impl ShutdownToken
Sourcepub fn is_shutdown(&self) -> bool
pub fn is_shutdown(&self) -> bool
Returns true iff shutdown has been triggered.
Contract: once true, this will remain true for the lifetime of the token.
Sourcepub fn wait(&self)
pub fn wait(&self)
Block the current thread until shutdown is triggered.
Panics: panics if the internal mutex is poisoned.
Sourcepub fn wait_timeout(&self, timeout: Duration) -> bool
pub fn wait_timeout(&self, timeout: Duration) -> bool
Block the current thread until shutdown is triggered, or the timeout elapses.
Returns true if shutdown was observed.
Panics: panics if the internal mutex is poisoned.
Trait Implementations§
Source§impl Clone for ShutdownToken
impl Clone for ShutdownToken
Source§fn clone(&self) -> ShutdownToken
fn clone(&self) -> ShutdownToken
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ShutdownToken
impl RefUnwindSafe for ShutdownToken
impl Send for ShutdownToken
impl Sync for ShutdownToken
impl Unpin for ShutdownToken
impl UnwindSafe for ShutdownToken
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
Mutably borrows from an owned value. Read more