From Jason Turner

[exec.run.loop.general]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp84zo369j/{from.md → to.md} +52 -0
tmp/tmp84zo369j/{from.md → to.md} RENAMED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### General <a id="exec.run.loop.general">[[exec.run.loop.general]]</a>
2
+
3
+ A `run_loop` is an execution resource on which work can be scheduled. It
4
+ maintains a thread-safe first-in-first-out queue of work. Its `run`
5
+ member function removes elements from the queue and executes them in a
6
+ loop on the thread of execution that calls `run`.
7
+
8
+ A `run_loop` instance has an associated *count* that corresponds to the
9
+ number of work items that are in its queue. Additionally, a `run_loop`
10
+ instance has an associated state that can be one of *starting*,
11
+ *running*, *finishing*, or *finished*.
12
+
13
+ Concurrent invocations of the member functions of `run_loop` other than
14
+ `run` and its destructor do not introduce data races. The member
15
+ functions *`pop-front`*, *`push-back`*, and `finish` execute atomically.
16
+
17
+ *Recommended practice:* Implementations should use an intrusive queue of
18
+ operation states to hold the work units to make scheduling
19
+ allocation-free.
20
+
21
+ ``` cpp
22
+ namespace std::execution {
23
+ class run_loop {
24
+ // [exec.run.loop.types], associated types
25
+ class run-loop-scheduler; // exposition only
26
+ class run-loop-sender; // exposition only
27
+ struct run-loop-opstate-base { // exposition only
28
+ virtual void execute() = 0; // exposition only
29
+ run_loop* loop; // exposition only
30
+ run-loop-opstate-base* next; // exposition only
31
+ };
32
+ template<class Rcvr>
33
+ using run-loop-opstate = unspecified; // exposition only
34
+
35
+ // [exec.run.loop.members], member functions
36
+ run-loop-opstate-base* pop-front(); // exposition only
37
+ void push-back(run-loop-opstate-base*); // exposition only
38
+
39
+ public:
40
+ // [exec.run.loop.ctor], constructor and destructor
41
+ run_loop() noexcept;
42
+ run_loop(run_loop&&) = delete;
43
+ ~run_loop();
44
+
45
+ // [exec.run.loop.members], member functions
46
+ run-loop-scheduler get_scheduler();
47
+ void run();
48
+ void finish();
49
+ };
50
+ }
51
+ ```
52
+