Struct parking_lot_core::SpinWait [−][src]
pub struct SpinWait { /* fields omitted */ }
A counter used to perform exponential backoff in spin loops.
Methods
impl SpinWait
[src]
impl SpinWait
pub fn new() -> SpinWait
[src]
pub fn new() -> SpinWait
Creates a new SpinWait
.
pub fn reset(&mut self)
[src]
pub fn reset(&mut self)
Resets a SpinWait
to its initial state.
pub fn spin(&mut self) -> bool
[src]
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.
pub fn spin_no_yield(&mut self)
[src]
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.