carb::this_thread::spinWaitWithBackoff
Defined in carb/thread/Util.h
- 
template<class Func>
 void carb::this_thread::spinWaitWithBackoff(Func &&f) noexcept(noexcept(f()))
- Calls a predicate until it returns true with progressively increasing delays between calls. - This function is a low-level utility for high-contention cases where multiple threads will be calling - fsimultaneously,- fneeds to succeed (return- true) before continuing, but- fwill only succeed for one thread at a time. This function does not return until- freturns- true, at which point this function returns immediately. High contention is assumed when- freturns- falsefor several calls, at which point the calling thread will invoke- std::this_thread::yield()between calls to- f. This is a back-off mechanism to allow one thread to move forward while other competing threads wait their turn.- Note - This function does not return until - fhas returned- truefor the calling thread. For a version of this function that will give up, use spinTryWaitWithBackoff().- Note - This function may enter the kernel to wait. - Parameters
- f – The predicate to call repeatedly until it returns - true.