Files
cppdraft_translate/cppdraft/exec/run/loop/members.md
2025-10-25 03:02:53 +03:00

3.1 KiB
Raw Blame History

[exec.run.loop.members]

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();

1

#

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

count is 0 and state is finishing, in which case pop-front sets state to finished and returns nullptr; or

count is greater than 0, in which case an item is removed from the front of the queue,count is decremented by 1, and the removed item is returned.

🔗

void push-back(run-loop-opstate-base* item);

2

#

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

3

#

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

🔗

run-loop-scheduler get_scheduler();

4

#

Returns: An instance of run-loop-scheduler that can be used to schedule work onto this run_loop instance.

🔗

void run();

5

#

Preconditions: state is either starting or finishing.

6

#

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

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

7

#

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

🔗

void finish();

8

#

Preconditions: state is either starting or running.

9

#

Effects: Changes state to finishing.

10

#

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