pub struct BoxedStop(/* private fields */);👎Deprecated since 0.4.5:
use StopToken, which checks the same way and is Clone
Expand description
A type-erased Stop with unique ownership. Deprecated: use
StopToken, which checks the same way and is Clone.
BoxedStop wraps a StopToken: no-op stops (like Unstoppable) are stored
as nothing and never dispatched, a Stopper is checked as a direct atomic
load without a vtable, a SyncStopper keeps its own Arc behind the
vtable, and wrapping a StopToken or another BoxedStop reuses it instead
of nesting. Anything else is allocated and checked through a vtable.
§Example
use almost_enough::{BoxedStop, StopSource, Stopper, Unstoppable, Stop};
fn process(stop: BoxedStop) {
for i in 0..1000 {
if i % 100 == 0 && stop.should_stop() {
return;
}
// process...
}
}
// Works with any Stop implementation
process(BoxedStop::new(Unstoppable));
process(BoxedStop::new(StopSource::new()));
process(BoxedStop::new(Stopper::new()));Implementations§
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for BoxedStop
impl !UnwindSafe for BoxedStop
impl Freeze for BoxedStop
impl Send for BoxedStop
impl Sync for BoxedStop
impl Unpin for BoxedStop
impl UnsafeUnpin for BoxedStop
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
Source§impl<T> DebouncedTimeoutExt for Twhere
T: Stop,
impl<T> DebouncedTimeoutExt for Twhere
T: Stop,
Source§fn with_debounced_timeout(self, duration: Duration) -> DebouncedTimeout<Self>
fn with_debounced_timeout(self, duration: Duration) -> DebouncedTimeout<Self>
Add a debounced timeout to this stop. Read more
Source§fn with_debounced_deadline(self, deadline: Instant) -> DebouncedTimeout<Self>
fn with_debounced_deadline(self, deadline: Instant) -> DebouncedTimeout<Self>
Add a debounced timeout with an absolute deadline.
Source§impl<T> StopExt for Twhere
T: Stop,
impl<T> StopExt for Twhere
T: Stop,
Source§fn or<S: Stop>(self, other: S) -> OrStop<Self, S>
fn or<S: Stop>(self, other: S) -> OrStop<Self, S>
Combine this stop with another, stopping if either stops. Read more
Source§fn into_boxed(self) -> BoxedStopwhere
Self: 'static,
fn into_boxed(self) -> BoxedStopwhere
Self: 'static,
👎Deprecated since 0.4.5:
use into_token(), whose StopToken checks the same way and is Clone
Convert this stop into a
BoxedStop. Deprecated: use
into_token(), whose StopToken checks the
same way and is Clone.Source§fn into_token(self) -> StopTokenwhere
Self: 'static,
fn into_token(self) -> StopTokenwhere
Self: 'static,
Source§impl<T> TimeoutExt for Twhere
T: Stop,
impl<T> TimeoutExt for Twhere
T: Stop,
Source§fn with_timeout(self, duration: Duration) -> WithTimeout<Self>
fn with_timeout(self, duration: Duration) -> WithTimeout<Self>
Add a timeout to this stop. Read more
Source§fn with_deadline(self, deadline: Instant) -> WithTimeout<Self>
fn with_deadline(self, deadline: Instant) -> WithTimeout<Self>
Add an absolute deadline to this stop. Read more