spinTryWait#
Fully qualified name: carb::this_thread::spinTryWait
Defined in carb/thread/Util.h
-
template<class Func>
bool carb::this_thread::spinTryWait( - Func &&f,
Calls a predicate until it returns true or a number of attempts have elapsed.
This function is recommended only for situations where exactly one thread is waiting on another thread. For multiple threads waiting on a predicate, use spinTryWaitWithBackoff().
This function will call
finterspersed with increasing invocations of CARB_HARDWARE_PAUSE. After a certain number of attempts, the function gives up and returnsfalse. Iffreturnstrue, spinTryWait() immediately returnstrue.Note
This function does not enter the kernel to wait.
- Parameters:
f – The predicate to call repeatedly until it returns
true.- Returns:
trueimmediately whenfreturnstrue. If a number of attempts to callfall returnfalsethen the function gives up andfalseis returned.