pub struct KillSwitch { /* private fields */ }
Expand description
Convenience type which wraps a AtomicBool
.
Initially, is_alive()
will return true
. The value can be cloned across threads, and once it
has been kill()
ed, then all of the clones will return false
from is_alive()
.
Implementations§
Source§impl KillSwitch
impl KillSwitch
Sourcepub fn is_alive(&self) -> bool
pub fn is_alive(&self) -> bool
Check if the kill switch has been flipped. Before flipping will return true
, and
afterwards will return false
Sourcepub fn kill(&self) -> Result<(), KillSwitchErr>
pub fn kill(&self) -> Result<(), KillSwitchErr>
Flip the kill switch (will cause is_alive()
to return false
Sourcepub fn watcher(&self) -> KillSwitchWatcher
pub fn watcher(&self) -> KillSwitchWatcher
Produce a kill switch which can only watch the value, but cannot flip the switch
Trait Implementations§
Source§impl Clone for KillSwitch
impl Clone for KillSwitch
Source§fn clone(&self) -> KillSwitch
fn clone(&self) -> KillSwitch
Returns a copy 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 moreSource§impl Debug for KillSwitch
impl Debug for KillSwitch
Source§impl Default for KillSwitch
impl Default for KillSwitch
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