1.24.0[−][src]Function sp_std::sync::atomic::spin_loop_hint
pub fn spin_loop_hint()
Signals the processor that it is inside a busy-wait spin-loop ("spin lock").
Upon receiving spin-loop signal the processor can optimize its behavior by, for example, saving power or switching hyper-threads.
This function is different from std::thread::yield_now
which directly yields to the
system's scheduler, whereas spin_loop_hint
does not interact with the operating system.
A common use case for spin_loop_hint
is implementing bounded optimistic spinning in a CAS
loop in synchronization primitives. To avoid problems like priority inversion, it is strongly
recommended that the spin loop is terminated after a finite amount of iterations and an
appropriate blocking syscall is made.
Note: On platforms that do not support receiving spin-loop hints this function does not do anything at all.