MySQL 8.4.0
Source Code Documentation
os0event.ic File Reference

Inlined implementation for os_event_*. More...

Functions

template<typename Condition >
static Wait_stats os_event_wait_for (os_event_t &event, uint64_t spins_limit, std::chrono::microseconds timeout, Condition condition={})
 Waits in loop until a provided condition is satisfied. More...
 

Detailed Description

Inlined implementation for os_event_*.

Function Documentation

◆ os_event_wait_for()

template<typename Condition >
static Wait_stats os_event_wait_for ( os_event_t event,
uint64_t  spins_limit,
std::chrono::microseconds  timeout,
Condition  condition = {} 
)
inlinestatic

Waits in loop until a provided condition is satisfied.

Combines usage of spin-delay and event.

Remarks
First it uses a spin loop with PAUSE instructions. In each spin iteration it checks the condition and stops as soon as it returned true.

When a provided number of spin iterations is reached, and the condition still has not returned true, waiting on a provided event starts.

Each wait uses a provided timeout. After each wake-up the condition is re-checked and function stops as soon as the condition returned true.

Every k-waits (ended on wake-up or timeout), the timeout is multiplied by two (but it's limited up to maximum value of 100ms).

Parameters
[in,out]eventevent on which function may wait
[in]spins_limitmaximum spin iterations
[in]timeoutinitial timeout value
[in]conditionreturns true when condition is satisfied
Returns
number of loops with wait on event that have been used