[exec.run.loop.members] (original) (raw)

33 Execution control library [exec]

33.12 Execution contexts [exec.ctx]

33.12.1 execution​::​run_loop [exec.run.loop]

33.12.1.4 Member functions [exec.run.loop.members]

_run-loop-opstate-base_* _pop-front_();

Effects: Blocks ([defns.block]) until one of the following conditions is true:

void _push-back_(_run-loop-opstate-base_* item);

Effects: Adds item to the back of the queue and increments count by 1.

Synchronization: This operation synchronizes with the pop-front operation that obtains item.

_run-loop-scheduler_ get_scheduler();

Returns: An instance of _run-loop-scheduler_that can be used to schedule work onto this run_loop instance.

Preconditions: state is either starting or finishing.

Effects: If state is starting, sets the state to running, otherwise leaves state unchanged.

Then, equivalent to:while (auto* op = pop-front()) { op->execute();}

Remarks: When state changes, it does so without introducing data races.

Preconditions: state is either starting or running.

Effects: Changes state to finishing.

Synchronization: finish synchronizes with the pop-front operation that returns nullptr.