pub struct SyncStopper { /* private fields */ }Expand description
A cancellation primitive with Release/Acquire memory ordering.
Unlike Stopper which uses Relaxed ordering,
SyncStopper guarantees that all writes before cancel() are visible
to any clone that subsequently observes should_stop() == true.
Converts to StopToken via From/Into with zero
overhead — the existing Arc is reused, not double-wrapped.
§Performance
On x86/x64, Release/Acquire has negligible overhead (strong memory model).
On ARM and other weakly-ordered architectures, there’s a small cost for
the memory barriers. Use Stopper if you don’t
need the synchronization guarantees.
Implementations§
Source§impl SyncStopper
impl SyncStopper
Sourcepub fn cancel(&self)
pub fn cancel(&self)
Cancel with Release ordering.
All memory writes before this call are guaranteed to be visible
to any clone that subsequently observes should_stop() == true.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Check if cancelled with Acquire ordering.
If this returns true, all memory writes that happened before
the corresponding cancel() call are guaranteed to be visible.
Trait Implementations§
Source§impl Clone for SyncStopper
impl Clone for SyncStopper
Source§fn clone(&self) -> SyncStopper
fn clone(&self) -> SyncStopper
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SyncStopper
impl Debug for SyncStopper
Source§impl Default for SyncStopper
impl Default for SyncStopper
Source§impl From<SyncStopper> for StopToken
Zero-cost conversion: reuses the SyncStopper’s existing Arc via pointer widening.
impl From<SyncStopper> for StopToken
Zero-cost conversion: reuses the SyncStopper’s existing Arc via pointer widening.