pub struct SpinWait { /* private fields */ }
Expand description
A counter used to perform exponential backoff in spin loops.
Implementations§
Source§impl SpinWait
impl SpinWait
Sourcepub fn spin(&mut self) -> bool
pub fn spin(&mut self) -> bool
Spins until the sleep threshold has been reached.
This function returns whether the sleep threshold has been reached, at which point further spinning has diminishing returns and the thread should be parked instead.
The spin strategy will initially use a CPU-bound loop but will fall back to yielding the CPU to the OS after a few iterations.
Sourcepub fn spin_no_yield(&mut self)
pub fn spin_no_yield(&mut self)
Spins without yielding the thread to the OS.
Instead, the backoff is simply capped at a maximum value. This can be
used to improve throughput in compare_exchange
loops that have high
contention.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SpinWait
impl RefUnwindSafe for SpinWait
impl Send for SpinWait
impl Sync for SpinWait
impl Unpin for SpinWait
impl UnwindSafe for SpinWait
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
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 4 bytes