pub struct BoxedStop(/* private fields */);Expand description
A heap-allocated Stop implementation.
Prefer StopToken which is Clone (via Arc) and
supports indirection collapsing. BoxedStop is retained for cases where
unique ownership is required.
No-op stops (like Unstoppable) are optimized away at construction —
check() short-circuits without any vtable dispatch.
§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 Freeze for BoxedStop
impl !RefUnwindSafe for BoxedStop
impl Send for BoxedStop
impl Sync for BoxedStop
impl Unpin for BoxedStop
impl UnsafeUnpin for BoxedStop
impl !UnwindSafe 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> StopExt for Twhere
T: Stop,
impl<T> StopExt for Twhere
T: Stop,
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