Skip to content

Commit 011574c

Browse files
jensmaurertkoeppe
authored andcommitted
P3396R1 std::execution wording fixes
Editorial notes: * Replace 'one of' with 'either'. * Replace 'Where' with more appropriate phrasing.
1 parent b851a6b commit 011574c

File tree

1 file changed

+79
-34
lines changed

1 file changed

+79
-34
lines changed

source/exec.tex

Lines changed: 79 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@
9191
\item
9292
\tcode{err} if \tcode{decay_t<Err>} denotes the type \tcode{exception_ptr}.
9393

94-
\mandates
95-
\tcode{err != exception_ptr()} is \tcode{true}.
94+
\expects
95+
\tcode{!err} is \tcode{false}.
9696
\item
9797
Otherwise,
9898
\tcode{make_exception_ptr(system_error(err))}
@@ -229,7 +229,6 @@
229229
representing the execution-time properties of the operation's caller.
230230
The caller of an asynchronous operation is
231231
its parent operation or the function that created it.
232-
An asynchronous operation's operation state owns the operation's environment.
233232

234233
\pnum
235234
An asynchronous operation has an associated receiver.
@@ -1012,7 +1011,7 @@
10121011
-> @\libconcept{same_as}@<remove_cvref_t<Sch>>;
10131012
} &&
10141013
@\libconcept{equality_comparable}@<remove_cvref_t<Sch>> &&
1015-
@\libconcept{copy_constructible}@<remove_cvref_t<Sch>>;
1014+
@\libconcept{copyable}@<remove_cvref_t<Sch>>;
10161015
}
10171016
\end{codeblock}
10181017

@@ -1025,17 +1024,15 @@
10251024
shall be modeled.
10261025

10271026
\pnum
1028-
None of a scheduler's
1029-
copy constructor,
1030-
destructor,
1031-
equality comparison, or
1032-
\tcode{swap} member functions
1027+
No operation required by
1028+
\tcode{\libconcept{copyable}<remove_cvref_t<Sch>>} and
1029+
\tcode{\libconcept{equality_comparable}<remove_cvref_t<Sch>>}
10331030
shall exit via an exception.
1034-
None of these member functions,
1031+
None of these operations,
10351032
nor a scheduler type's \tcode{schedule} function,
10361033
shall introduce data races
10371034
as a result of potentially concurrent\iref{intro.races} invocations
1038-
of those functions from different threads.
1035+
of those operations from different threads.
10391036

10401037
\pnum
10411038
For any two values \tcode{sch1} and \tcode{sch2}
@@ -1727,10 +1724,16 @@
17271724

17281725
\pnum
17291726
The expression in the \tcode{noexcept} clause of
1730-
the constructor of \exposid{basic-state} is:
1727+
the constructor of \exposid{basic-state} is
17311728
\begin{codeblock}
17321729
is_nothrow_move_constructible_v<Rcvr> &&
1733-
@\exposconcept{nothrow-callable}@<decltype(@\exposid{impls-for}@<tag_of_t<Sndr>>::@\exposid{get-state}@), Sndr, Rcvr&>
1730+
@\exposconcept{nothrow-callable}@<decltype(@\exposid{impls-for}@<tag_of_t<Sndr>>::@\exposid{get-state}@), Sndr, Rcvr&> &&
1731+
(same_as<@\exposid{state-type}@<Sndr, Rcvr>, @\exposid{get-state-result}@> ||
1732+
is_nothrow_constructible_v<@\exposid{state-type}@<Sndr, Rcvr>, @\exposid{get-state-result}@>)
1733+
\end{codeblock}
1734+
where \exposid{get-state-result} is
1735+
\begin{codeblock}
1736+
@\exposid{call-result-t}@<decltype(@\exposid{impls-for}@<tag_of_t<Sndr>>::@\exposid{get-state}@), Sndr, Rcvr&>.
17341737
\end{codeblock}
17351738

17361739
\pnum
@@ -1879,11 +1882,24 @@
18791882
struct @\exposid{impls-for}@<@\exposid{write-env-t}@> : @\exposid{default-impls}@ {
18801883
static constexpr auto @\exposid{get-env}@ =
18811884
[](auto, const auto& state, const auto& rcvr) noexcept {
1882-
return @\exposid{JOIN-ENV}@(state, get_env(rcvr));
1885+
return @\seebelow@;
18831886
};
18841887
};
18851888
\end{codeblock}
18861889
\end{itemdescr}
1890+
Invocation of
1891+
\tcode{\exposid{impls-for}<\exposid{write-env-t}>::\exposid{get-env}}
1892+
returns an object \tcode{e} such that
1893+
\begin{itemize}
1894+
\item
1895+
\tcode{decltype(e)} models \exposconcept{queryable} and
1896+
\item
1897+
given a query object \tcode{q},
1898+
the expression \tcode{e.query(q)} is expression-equivalent
1899+
to \tcode{state.query(q)} if that expression is valid,
1900+
otherwise, \tcode{e.query(q)} is expression-equivalent
1901+
to \tcode{get_env(rcvr).query(q)}.
1902+
\end{itemize}
18871903

18881904
\rSec2[exec.snd.concepts]{Sender concepts}
18891905

@@ -2455,14 +2471,13 @@
24552471
Let \exposid{operation-state-task} be the following exposition-only class:
24562472
\begin{codeblock}
24572473
namespace std::execution {
2458-
struct @\exposid{operation-state-task}@ {
2474+
struct @\exposid{operation-state-task}@ { // \expos
24592475
using operation_state_concept = operation_state_t;
24602476
using promise_type = @\exposid{connect-awaitable-promise}@;
24612477

24622478
explicit @\exposid{operation-state-task}@(coroutine_handle<> h) noexcept : coro(h) {}
2463-
@\exposid{operation-state-task}@(@\exposid{operation-state-task}@&& o) noexcept
2464-
: @\exposid{coro}@(exchange(o.@\exposid{coro}@, {})) {}
2465-
~@\exposid{operation-state-task}@() { if (@\exposid{coro}@) @\exposid{coro}@.destroy(); }
2479+
@\exposid{operation-state-task}@(@\exposid{operation-state-task}@&&) = delete;
2480+
~@\exposid{operation-state-task}@() { @\exposid{coro}@.destroy(); }
24662481

24672482
void start() & noexcept {
24682483
@\exposid{coro}@.resume();
@@ -3053,15 +3068,14 @@
30533068
using result_t = @\exposid{decayed-tuple}@<Tag, Args...>;
30543069
constexpr bool nothrow = is_nothrow_constructible_v<result_t, Tag, Args...>;
30553070

3056-
@\exposid{TRY-EVAL}@(rcvr, [&]() noexcept(nothrow) {
3071+
try {
30573072
state.@\exposid{async-result}@.template emplace<result_t>(Tag(), std::forward<Args>(args)...);
3058-
}());
3059-
3060-
if (state.@\exposid{async-result}@.valueless_by_exception())
3061-
return;
3062-
if (state.@\exposid{async-result}@.index() == 0)
3063-
return;
3064-
3073+
} catch (...) {
3074+
if constexpr (!nothrow) {
3075+
set_error(std::move(rcvr), current_exception());
3076+
return;
3077+
}
3078+
}
30653079
start(state.@\exposid{op-state}@);
30663080
};
30673081
\end{codeblock}
@@ -3448,14 +3462,26 @@
34483462
}
34493463

34503464
decltype(auto) get_env() const noexcept {
3451-
return @\exposid{JOIN-ENV}@(@\exposid{env}@, @\exposid{FWD-ENV}@(execution::get_env(@\exposid{rcvr}@)));
3465+
return @\seebelow@;
34523466
}
34533467

34543468
Rcvr& @\exposid{rcvr}@; // \expos
34553469
Env @\exposid{env}@; // \expos
34563470
};
34573471
}
34583472
\end{codeblock}
3473+
Invocation of the function \tcode{\exposid{receiver2}::get_env}
3474+
returns an object \tcode{e} such that
3475+
\begin{itemize}
3476+
\item
3477+
\tcode{decltype(e)} models \exposconcept{queryable} and
3478+
\item
3479+
given a query object \tcode{q},
3480+
the expression \tcode{e.query(q)} is expression-equivalent
3481+
to \tcode{\exposid{env}.query(q)} if that expression is valid,
3482+
otherwise \tcode{e.query(q)} is expression-equivalent
3483+
to \tcode{get_env(\exposid{rcvr}).query(q)}.
3484+
\end{itemize}
34593485

34603486
\pnum
34613487
\tcode{\exposid{impls-for}<\exposid{decayed-typeof}<\exposid{let-cpo}>>::\exposid{get-state}}
@@ -3647,7 +3673,7 @@
36473673
\item
36483674
on a value completion operation,
36493675
invokes \tcode{f(i, args...)}
3650-
for every \tcode{i} of type \tcode{Shape} from \tcode{0} to \tcode{shape},
3676+
for every \tcode{i} of type \tcode{Shape} in \range{\tcode{0}}{\tcode{shape}},
36513677
where \tcode{args} is a pack of lvalue subexpressions
36523678
referring to the value completion result datums of the input sender, and
36533679
\item
@@ -4101,10 +4127,20 @@
41014127
equivalent to the following lambda expression:
41024128
\begin{codeblock}
41034129
[]<class State, class Rcvr>(auto&&, State& state, const Receiver& rcvr) noexcept {
4104-
return @\exposid{JOIN-ENV}@(
4105-
@\exposid{MAKE-ENV}@(get_stop_token, state.@\exposid{stop_src}@.get_token()), get_env(rcvr));
4130+
return @\seebelow@;
41064131
}
41074132
\end{codeblock}
4133+
Returns an object \tcode{e} such that
4134+
\begin{itemize}
4135+
\item
4136+
\tcode{decltype(e)} models \exposconcept{queryable}, and
4137+
\item
4138+
\tcode{e.query(get_stop_token)} is expression-equivalent to
4139+
\tcode{state.\exposid{stop-src}.get_token()}, and
4140+
\item
4141+
given a query object \tcode{q} with type other than \cv{} \tcode{stop_token_t},
4142+
\tcode{e.query(q)} is expression-equivalent to \tcode{get_env(rcvr).query(q)}.
4143+
\end{itemize}
41084144

41094145
\pnum
41104146
The member \tcode{\exposid{impls-for}<when_all_t>::\exposid{get-state}}
@@ -4957,7 +4993,8 @@
49574993
A \tcode{run_loop} instance has an associated \defn{count}
49584994
that corresponds to the number of work items that are in its queue.
49594995
Additionally, a \tcode{run_loop} instance has an associated state
4960-
that can be one of \defn{starting}, \defn{running}, or \defn{finishing}.
4996+
that can be one of
4997+
\defn{starting}, \defn{running}, \defn{finishing}, or \defn{finished}.
49614998

49624999
\pnum
49635000
Concurrent invocations of the member functions of \tcode{run_loop}
@@ -5146,7 +5183,8 @@
51465183
\begin{itemize}
51475184
\item
51485185
\exposid{count} is \tcode{0} and \exposid{state} is \exposid{finishing},
5149-
in which case \exposid{pop-front} returns \tcode{nullptr}; or
5186+
in which case \exposid{pop-front} sets \exposid{state} to \exposid{finished}
5187+
and returns \tcode{nullptr}; or
51505188
\item
51515189
\exposid{count} is greater than \tcode{0},
51525190
in which case an item is removed from the front of the queue,
@@ -5191,11 +5229,14 @@
51915229
\begin{itemdescr}
51925230
\pnum
51935231
\expects
5194-
\exposid{state} is \exposid{starting}.
5232+
\exposid{state} is either \exposid{starting} or \exposid{finishing}.
51955233

51965234
\pnum
51975235
\effects
5198-
Sets the \exposid{state} to \exposid{running}. Then, equivalent to:
5236+
If \exposid{state} is \exposid{starting},
5237+
sets the \exposid{state} to \exposid{running},
5238+
otherwise leaves \exposid{state} unchanged.
5239+
Then, equivalent to:
51995240
\begin{codeblock}
52005241
while (auto* op = @\exposid{pop-front}@()) {
52015242
op->@\exposid{execute}@();
@@ -5213,6 +5254,10 @@
52135254
\end{itemdecl}
52145255

52155256
\begin{itemdescr}
5257+
\pnum
5258+
\expects
5259+
\exposid{state} is either \exposid{starting} or \exposid{running}.
5260+
52165261
\pnum
52175262
\effects
52185263
Changes \exposid{state} to \exposid{finishing}.

0 commit comments

Comments
 (0)