From Jason Turner

[exec.async.ops]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmplliyxt_5/{from.md → to.md} +169 -0
tmp/tmplliyxt_5/{from.md → to.md} RENAMED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Asynchronous operations <a id="exec.async.ops">[[exec.async.ops]]</a>
2
+
3
+ An *execution resource* is a program entity that manages a (possibly
4
+ dynamic) set of execution agents [[thread.req.lockable.general]], which
5
+ it uses to execute parallel work on behalf of callers.
6
+
7
+ [*Example 1*: The currently active thread, a system-provided thread
8
+ pool, and uses of an API associated with an external hardware
9
+ accelerator are all examples of execution resources. — *end example*]
10
+
11
+ Execution resources execute asynchronous operations. An execution
12
+ resource is either valid or invalid.
13
+
14
+ An *asynchronous operation* is a distinct unit of program execution that
15
+
16
+ - is explicitly created;
17
+ - can be explicitly started once at most;
18
+ - once started, eventually completes exactly once with a (possibly
19
+ empty) set of result datums and in exactly one of three
20
+ *dispositions*: success, failure, or cancellation;
21
+ - A successful completion, also known as a *value completion*, can
22
+ have an arbitrary number of result datums.
23
+ - A failure completion, also known as an *error completion*, has a
24
+ single result datum.
25
+ - A cancellation completion, also known as a *stopped completion*, has
26
+ no result datum.
27
+
28
+ An asynchronous operation’s *async result* is its disposition and its
29
+ (possibly empty) set of result datums.
30
+ - can complete on a different execution resource than the execution
31
+ resource on which it started; and
32
+ - can create and start other asynchronous operations called
33
+ *child operations*. A child operation is an asynchronous operation
34
+ that is created by the parent operation and, if started, completes
35
+ before the parent operation completes. A *parent operation* is the
36
+ asynchronous operation that created a particular child operation.
37
+
38
+ [*Note 1*: An asynchronous operation can execute synchronously; that
39
+ is, it can complete during the execution of its start operation on the
40
+ thread of execution that started it. — *end note*]
41
+
42
+ An asynchronous operation has associated state known as its
43
+ *operation state*.
44
+
45
+ An asynchronous operation has an associated environment. An
46
+ *environment* is a queryable object [[exec.queryable]] representing the
47
+ execution-time properties of the operation’s caller. The caller of an
48
+ asynchronous operation is its parent operation or the function that
49
+ created it.
50
+
51
+ An asynchronous operation has an associated receiver. A *receiver* is an
52
+ aggregation of three handlers for the three asynchronous completion
53
+ dispositions:
54
+
55
+ - a value completion handler for a value completion,
56
+ - an error completion handler for an error completion, and
57
+ - a stopped completion handler for a stopped completion.
58
+
59
+ A receiver has an associated environment. An asynchronous operation’s
60
+ operation state owns the operation’s receiver. The environment of an
61
+ asynchronous operation is equal to its receiver’s environment.
62
+
63
+ For each completion disposition, there is a *completion function*. A
64
+ completion function is a customization point object
65
+ [[customization.point.object]] that accepts an asynchronous operation’s
66
+ receiver as the first argument and the result datums of the asynchronous
67
+ operation as additional arguments. The value completion function invokes
68
+ the receiver’s value completion handler with the value result datums;
69
+ likewise for the error completion function and the stopped completion
70
+ function. A completion function has an associated type known as its
71
+ *completion tag* that is the unqualified type of the completion
72
+ function. A valid invocation of a completion function is called a
73
+ *completion operation*.
74
+
75
+ The *lifetime of an asynchronous operation*, also known as the
76
+ operation’s *async lifetime*, begins when its start operation begins
77
+ executing and ends when its completion operation begins executing. If
78
+ the lifetime of an asynchronous operation’s associated operation state
79
+ ends before the lifetime of the asynchronous operation, the behavior is
80
+ undefined. After an asynchronous operation executes a completion
81
+ operation, its associated operation state is invalid. Accessing any part
82
+ of an invalid operation state is undefined behavior.
83
+
84
+ An asynchronous operation shall not execute a completion operation
85
+ before its start operation has begun executing. After its start
86
+ operation has begun executing, exactly one completion operation shall
87
+ execute. The lifetime of an asynchronous operation’s operation state can
88
+ end during the execution of the completion operation.
89
+
90
+ A *sender* is a factory for one or more asynchronous operations.
91
+ *Connecting* a sender and a receiver creates an asynchronous operation.
92
+ The asynchronous operation’s associated receiver is equal to the
93
+ receiver used to create it, and its associated environment is equal to
94
+ the environment associated with the receiver used to create it. The
95
+ lifetime of an asynchronous operation’s associated operation state does
96
+ not depend on the lifetimes of either the sender or the receiver from
97
+ which it was created. A sender is started when it is connected to a
98
+ receiver and the resulting asynchronous operation is started. A sender’s
99
+ async result is the async result of the asynchronous operation created
100
+ by connecting it to a receiver. A sender sends its results by way of the
101
+ asynchronous operation(s) it produces, and a receiver receives those
102
+ results. A sender is either valid or invalid; it becomes invalid when
103
+ its parent sender (see below) becomes invalid.
104
+
105
+ A *scheduler* is an abstraction of an execution resource with a uniform,
106
+ generic interface for scheduling work onto that resource. It is a
107
+ factory for senders whose asynchronous operations execute value
108
+ completion operations on an execution agent belonging to the scheduler’s
109
+ associated execution resource. A *schedule-expression* obtains such a
110
+ sender from a scheduler. A *schedule sender* is the result of a schedule
111
+ expression. On success, an asynchronous operation produced by a schedule
112
+ sender executes a value completion operation with an empty set of result
113
+ datums. Multiple schedulers can refer to the same execution resource. A
114
+ scheduler can be valid or invalid. A scheduler becomes invalid when the
115
+ execution resource to which it refers becomes invalid, as do any
116
+ schedule senders obtained from the scheduler, and any operation states
117
+ obtained from those senders.
118
+
119
+ An asynchronous operation has one or more associated completion
120
+ schedulers for each of its possible dispositions. A *completion
121
+ scheduler* is a scheduler whose associated execution resource is used to
122
+ execute a completion operation for an asynchronous operation. A value
123
+ completion scheduler is a scheduler on which an asynchronous operation’s
124
+ value completion operation can execute. Likewise for error completion
125
+ schedulers and stopped completion schedulers.
126
+
127
+ A sender has an associated queryable object [[exec.queryable]] known as
128
+ its *attributes* that describes various characteristics of the sender
129
+ and of the asynchronous operation(s) it produces. For each disposition,
130
+ there is a query object for reading the associated completion scheduler
131
+ from a sender’s attributes; i.e., a value completion scheduler query
132
+ object for reading a sender’s value completion scheduler, etc. If a
133
+ completion scheduler query is well-formed, the returned completion
134
+ scheduler is unique for that disposition for any asynchronous operation
135
+ the sender creates. A schedule sender is required to have a value
136
+ completion scheduler attribute whose value is equal to the scheduler
137
+ that produced the schedule sender.
138
+
139
+ A *completion signature* is a function type that describes a completion
140
+ operation. An asynchronous operation has a finite set of possible
141
+ completion signatures corresponding to the completion operations that
142
+ the asynchronous operation potentially evaluates [[basic.def.odr]]. For
143
+ a completion function `set`, receiver `rcvr`, and pack of arguments
144
+ `args`, let `c` be the completion operation `set(rcvr, args...)`, and
145
+ let `F` be the function type `decltype(auto(set))(decltype((args))...)`.
146
+ A completion signature `Sig` is associated with `c` if and only if
147
+ `MATCHING-SIG(Sig, F)` is `true` [[exec.general]]. Together, a sender
148
+ type and an environment type `Env` determine the set of completion
149
+ signatures of an asynchronous operation that results from connecting the
150
+ sender with a receiver that has an environment of type `Env`. The type
151
+ of the receiver does not affect an asynchronous operation’s completion
152
+ signatures, only the type of the receiver’s environment. A
153
+ *non-dependent sender* is a sender type whose completion signatures are
154
+ knowable independent of an execution environment.
155
+
156
+ A sender algorithm is a function that takes and/or returns a sender.
157
+ There are three categories of sender algorithms:
158
+
159
+ - A *sender factory* is a function that takes non-senders as arguments
160
+ and that returns a sender.
161
+ - A *sender adaptor* is a function that constructs and returns a parent
162
+ sender from a set of one or more child senders and a (possibly empty)
163
+ set of additional arguments. An asynchronous operation created by a
164
+ parent sender is a parent operation to the child operations created by
165
+ the child senders.
166
+ - A *sender consumer* is a function that takes one or more senders and a
167
+ (possibly empty) set of additional arguments, and whose return type is
168
+ not the type of a sender.
169
+