pub struct KillSwitch { /* private fields */ }
Expand description
An object that can be used to terminate an instance’s execution from a separate thread.
Implementations§
Source§impl KillSwitch
impl KillSwitch
Sourcepub fn terminate(&self) -> Result<KillSuccess, KillError>
pub fn terminate(&self) -> Result<KillSuccess, KillError>
Signal the instance associated with this KillSwitch
to stop, if possible.
The returned Result
only describes the behavior taken by this function, not necessarily
what caused the associated instance to stop.
As an example, if a KillSwitch
fires, sending a SIGALRM to an instance at the same
moment it begins handling a SIGSEGV which is determined to be fatal, the instance may
stop with State::Faulted
before actually handling the SIGALRM we’d send here. So the
host code will see State::Faulted
as an instance state, where KillSwitch::terminate
would return Ok(KillSuccess::Signalled)
.
Auto Trait Implementations§
impl Freeze for KillSwitch
impl RefUnwindSafe for KillSwitch
impl Send for KillSwitch
impl Sync for KillSwitch
impl Unpin for KillSwitch
impl UnwindSafe for KillSwitch
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