@@ -2419,9 +2419,9 @@ first proposed in [[P2175R0]].
2419
2419
At a high-level, the facilities proposed by this paper for supporting
2420
2420
cancellation include:
2421
2421
2422
- * Add `std::stoppable_token` and `std::stoppable_token_for` concepts that
2423
- generalise the interface of `std::stop_token` type to allow other types with
2424
- different implementation strategies.
2422
+ * Add a `std::stoppable_token` concept that generalises the interface of the
2423
+ `std::stop_token` type to allow other stop token types with different
2424
+ implementation strategies.
2425
2425
* Add `std::unstoppable_token` concept for detecting whether a `stoppable_token`
2426
2426
can never receive a stop-request.
2427
2427
* Add `std::inplace_stop_token`, `std::inplace_stop_source` and
@@ -4120,21 +4120,20 @@ namespace std {
4120
4120
typically because the result is no longer required. Such a request is called
4121
4121
a <dfn export=true>stop request</dfn> .
4122
4122
4123
- 2. <code> stop<ins> pable</ins> _source</code> ,
4124
- <code> stop<ins> pable</ins> _token</code> , and
4125
- <code> stop<ins> pable</ins> _callback<ins> _for</ins></code>
4126
- <del> implement</del><ins> are concepts that specify the required syntax
4127
- and</ins> semantics of shared <del> ownership</del><ins> access</ins> of a
4128
- <dfn export=true>stop state</dfn> . Any
4129
- <code> stop<ins> pable</ins> _source</code> ,
4130
- <code> stop<ins> pable</ins> _token</code> , or
4131
- <code> stop<ins> pable</ins> _callback<ins> _for</ins></code> object that
4132
- <del> shares ownership of</del><ins> refers to</ins> the same stop state is an
4133
- <dfn export=true>associated</dfn> <code> stop<ins> pable</ins> _source</code> ,
4134
- <code> stop<ins> pable</ins> _token</code> , or
4135
- <code> stop<ins> pable</ins> _callback<ins> _for</ins></code> , respectively.
4136
- <del> The last remaining owner of the stop state automatically releases the
4137
- resources associated with the stop state.</del>
4123
+ 2. <del> `stop_source`, `stop_token`, and `stop_callback` implement</del>
4124
+ <ins><i> `stoppable-source`</i> , `stoppable_token`, and
4125
+ <i> `stoppable-callback-for`</i> are concepts that specify the required
4126
+ syntax and</ins> semantics of shared <del> ownership</del><ins> access</ins>
4127
+ of a <dfn export=true>stop state</dfn> . <del> Any `stop_source`,
4128
+ `stop_token`, or `stop_callback` object that shares ownership of the same
4129
+ stop state is an <i> **associated**</i> `stop_source`, `stop_token`, or
4130
+ `stop_callback`, respectively.</del> <ins> Any object modeling
4131
+ <i> `stoppable-source`</i> , `stoppable_token`, or
4132
+ <i> `stoppable-callback-for`</i> that refers to the same stop state is an
4133
+ <dfn export=true>associated</dfn> <i> `stoppable-source`</i> ,
4134
+ `stoppable_token`, or <i> `stoppable-callback-for`</i> ,
4135
+ respectively.</ins><del> The last remaining owner of the stop state
4136
+ automatically releases the resources associated with the stop state.</del>
4138
4137
4139
4138
3. A <code> stop<ins> pable</ins> _token</code> can be passed to an operation <del>
4140
4139
which</del><ins> that</ins> can either
@@ -4147,28 +4146,27 @@ namespace std {
4147
4146
template which</del><ins> that</ins> will be called in the event that a
4148
4147
stop request is made.</div>
4149
4148
4150
- A stop request made via a <code> stop<ins> pable</ins> _source</code> will be
4151
- visible to all associated <code> stop<ins> pable</ins> _token</code> and
4152
- <code> stop<ins> pable</ins> _source</code> objects. Once a stop request has
4153
- been made it cannot be withdrawn (a subsequent stop request has no effect).
4149
+ A stop request made via <del> a `stop_source`</del><ins> an object that models
4150
+ <i> `stoppable-source`</i></ins> will be visible to all associated
4151
+ <code> stop<ins> pable</ins> _token</code> and <del> `stop_source`</del><ins>
4152
+ <i> `stoppable-source`</i></ins> objects. Once a stop request has been
4153
+ made it cannot be withdrawn (a subsequent stop request has no effect).
4154
4154
4155
- 4. Callbacks registered via a
4156
- <code> stop <ins> pable </ins> _callback <ins> _for < /ins></code> object are called
4157
- when a stop request is first made by any associated
4158
- <code> stop <ins> pable </ins> _source </code > object.
4155
+ 4. Callbacks registered via <del> a `stop_callback` object </del><ins> an object
4156
+ that models <i> `stoppable-callback-for` </i>< /ins> are called when a stop
4157
+ request is first made by any associated <del> `stop_source` </del><ins>
4158
+ <i> `stoppable-source` </i></ins > object.
4159
4159
4160
4160
<span class="ed-note"> The following paragraph is moved to the specification of
4161
- the new `stoppable_source` concept.</span>
4161
+ the new <i> `stoppable-source` </i> concept.</span>
4162
4162
4163
4163
<div class="del">
4164
4164
4165
4165
5. Calls to the functions `request_stop`, `stop_requested`, and `stop_possible`
4166
4166
do not introduce data races. A call to `request_stop` that returns `true`
4167
- synchronizes with a call to `stop_requested` on an associated
4168
- <code> stop<ins> pable</ins> _token</code> or
4169
- <code> stop<ins> pable</ins> _source</code> object that returns `true`.
4170
- Registration of a callback synchronizes with the invocation of that
4171
- callback.
4167
+ synchronizes with a call to `stop_requested` on an associated `stop_token`
4168
+ or `stop_source` object that returns `true`. Registration of a callback
4169
+ synchronizes with the invocation of that callback.
4172
4170
4173
4171
</div>
4174
4172
@@ -4195,7 +4193,7 @@ declarations into the `<stop_token>` synopsis:</span>
4195
4193
namespace std {
4196
4194
<div class="block-insert"> <i> // [stoptoken.concepts] , stop token concepts</i>
4197
4195
template<class Callback, class Token, class Initializer = Callback>
4198
- concept stoppable_callback_for = <i> see below</i> ;
4196
+ concept <i> stoppable-callback-for </i> = <i> see below</i> ; <i> // exposition only </i>
4199
4197
4200
4198
template<class Token>
4201
4199
concept stoppable_token = <i> see below</i> ;
@@ -4204,7 +4202,7 @@ namespace std {
4204
4202
concept unstoppable_token = <i> see below</i> ;
4205
4203
4206
4204
template<class Source>
4207
- concept stoppable_source = <i> see below</i> ;</div>
4205
+ concept <i> stoppable-source </i> = <i> see below</i> ; <i> // exposition only </i> </div>
4208
4206
// 33.3.3, class stop_token
4209
4207
class stop_token;
4210
4208
@@ -4253,12 +4251,12 @@ Header `<stop_token>` synopsis <b>[thread.stoptoken.syn]</b> and Class
4253
4251
arguments, if the type `stop_callback_for_t<Token, Callback>` is valid, it
4254
4252
denotes the type of a stop callback to use to register a callback to be
4255
4253
executed if a stop request is ever made on the `stoppable_token`'s
4256
- associated stop source. The `stoppable_callback_for` concept checks for a
4257
- callback compatible with a given stop token type.
4254
+ associated stop source. The exposition-only <i> `stoppable-callback- for` </i>
4255
+ concept checks for a callback compatible with a given stop token type.
4258
4256
4259
4257
<pre highlight="c++">
4260
4258
template<class Callback, class Token, class Initializer = Callback>
4261
- concept stoppable_callback_for =
4259
+ concept <i> stoppable-callback-for </i> = <i> // exposition only </i>
4262
4260
invocable<Callback> &&
4263
4261
constructible_from<Callback, Initializer> &&
4264
4262
requires { typename stop_callback_for_t<Token, Callback>; } &&
@@ -4270,8 +4268,8 @@ Header `<stop_token>` synopsis <b>[thread.stoptoken.syn]</b> and Class
4270
4268
`Initializer`; and let `CB` denote the type `stop_callback_for_t<Token,
4271
4269
Callback>`.
4272
4270
4273
- 3. The concept `stoppable_callback_for< Callback, Token, Initializer>` is modeled
4274
- only if:
4271
+ 3. The concept <code><i> stoppable-callback-for </i> < Callback, Token,
4272
+ Initializer> </code> is modeled only if:
4275
4273
4276
4274
1. The following concepts are modeled:
4277
4275
@@ -4390,27 +4388,29 @@ Header `<stop_token>` synopsis <b>[thread.stoptoken.syn]</b> and Class
4390
4388
after `E` shall evaluate to `true`.
4391
4389
4392
4390
3. For any types `Callback` and `Initializer`, if
4393
- `stoppable_callback_for<Callback, Token, Initializer>` is satisfied,
4394
- then `stoppable_callback_for<Callback, Token, Initializer>` shall be
4395
- modeled.
4396
-
4397
- 4. A `stoppable_token` object has at most one associated logical stop state.
4398
- A `stoppable_token` object with no associated stop state is said to be
4399
- <dfn export=true>disengaged</dfn> . For a disengaged `stoppable_token`
4400
- object, `stop_possible` and `stop_requested` shall return `false`. If
4401
- `t` and `u` reference the same stop state, or if both `t` and `u` are
4402
- disengaged, `t == u` shall be `true`; otherwise, it shall be `false`.
4403
-
4404
- 6. A model of `stoppable_source` can be queried whether stop has been requested
4405
- (`stop_requested`) and whether stop is possible (`stop_possible`). It is a
4406
- factory for associated stop tokens (`get_token`) and can be explicitly
4407
- placed into the "stop requested" state (`request_stop`). It maintains a list
4408
- of registered stop callback invocations that it executes when a stop request
4409
- is first made.
4391
+ <code><i> stoppable-callback-for</i> <Callback, Token,
4392
+ Initializer></code> is satisfied, then
4393
+ <code><i> stoppable-callback-for</i> <Callback, Token,
4394
+ Initializer></code> shall be modeled.
4395
+
4396
+ 4. An object that models `stoppable_token` has at most one associated
4397
+ logical stop state. A `stoppable_token` object with no associated stop
4398
+ state is said to be <dfn export=true>disengaged</dfn> . For a disengaged
4399
+ `stoppable_token` object, `stop_possible` and `stop_requested` shall
4400
+ return `false`. If `t` and `u` reference the same stop state, or if both
4401
+ `t` and `u` are disengaged, `t == u` shall be `true`; otherwise, it
4402
+ shall be `false`.
4403
+
4404
+ 6. A model of the exposition-only <i> `stoppable-source`</i> concept can be
4405
+ queried whether stop has been requested (`stop_requested`) and whether stop
4406
+ is possible (`stop_possible`). It is a factory for associated stop tokens
4407
+ (`get_token`) and can be explicitly placed into the "stop requested" state
4408
+ (`request_stop`). It maintains a list of registered stop callback
4409
+ invocations that it executes when a stop request is first made.
4410
4410
4411
4411
<pre highlight="c++">
4412
4412
template<class Source>
4413
- concept stoppable_source =
4413
+ concept <i> stoppable-source </i> = <i> // exposition only </i>
4414
4414
requires (Source& src, const Source csrc) { <i> // see implicit expression variations</i>
4415
4415
<i> // ([concepts.equality] )</i>
4416
4416
{ csrc.get_token() } -> stoppable_token;
@@ -4420,14 +4420,15 @@ Header `<stop_token>` synopsis <b>[thread.stoptoken.syn]</b> and Class
4420
4420
};
4421
4421
</pre>
4422
4422
4423
- 1. A `stoppable_source` object has at most one associated logical stop
4424
- state. A `stoppable_source` object with no associated stop state is said
4425
- to be disengaged. For a disengaged `stoppable_source` object,
4426
- `stop_possible` and `stop_requested` shall return `false`.
4423
+ 1. A <i> `stoppable-source`</i> object has at most one associated logical
4424
+ stop state. A <i> `stoppable-source`</i> object with no associated stop
4425
+ state is said to be disengaged. For a disengaged
4426
+ <i> `stoppable-source`</i> object, `stop_possible` and `stop_requested`
4427
+ shall return `false`.
4427
4428
4428
- 2. A disengaged `stoppable_source` object shall return a disengaged stop token
4429
- from `get_token()`. Otherwise, `get_token()` shall return a stop token that
4430
- is associated with the stop state of the source.
4429
+ 2. A disengaged <i> `stoppable-source` </i> object shall return a disengaged
4430
+ stop token from `get_token()`. Otherwise, `get_token()` shall return a
4431
+ stop token that is associated with the stop state of the source.
4431
4432
4432
4433
<span class="ed-note"> The following paragraph is moved from the introduction,
4433
4434
with minor modifications (underlined in green).</span>
@@ -4437,16 +4438,15 @@ Header `<stop_token>` synopsis <b>[thread.stoptoken.syn]</b> and Class
4437
4438
functions on associated `stoppable_token` objects</ins> do not introduce
4438
4439
data races. A call to `request_stop` that returns `true` synchronizes
4439
4440
with a call to `stop_requested` on an associated
4440
- <code> stop<ins> pable</ins> _token</code> or
4441
- <code> stop<ins> pable</ins> _source</code> object that returns `true`.
4442
- Registration of a callback synchronizes with the invocation of that
4443
- callback.
4441
+ <code> stop<ins> pable</ins> _token</code> or <del> `stop_source`</del><ins>
4442
+ <i> `stoppable-source`</i></ins> object that returns `true`. Registration
4443
+ of a callback synchronizes with the invocation of that callback.
4444
4444
4445
4445
<span class="ed-note"> The following paragraph is taken from
4446
4446
[[#spec-stopsource.mem]] and modified.</span>
4447
4447
4448
- 4. If the `stoppable_source` is disengaged, `request_stop` shall have no
4449
- effect and return `false`. Otherwise, it shall execute a <dfn
4448
+ 4. If the <i> `stoppable-source` </i> is disengaged, `request_stop` shall have
4449
+ no effect and return `false`. Otherwise, it shall execute a <dfn
4450
4450
export=true> stop request operation</dfn> on the associated stop state. A
4451
4451
stop request operation determines whether the stop state has received a
4452
4452
stop request, and if not, makes a stop request. The determination and
@@ -4638,7 +4638,7 @@ friend void swap(stop_token& x, stop_token& y) noexcept;
4638
4638
request. A stop request made on a `stop_source` object is visible to all
4639
4639
associated `stop_source` and `stop_token` ([thread.stoptoken] ) objects. Once
4640
4640
a stop request has been made it cannot be withdrawn (a subsequent stop
4641
- request has no effect)</del><ins> models `stoppable_source` </ins> .
4641
+ request has no effect)</del><ins> models <i> `stoppable-source` </i> </ins> .
4642
4642
4643
4643
<pre highlight="c++">
4644
4644
namespace std {
@@ -4881,10 +4881,12 @@ namespace std {
4881
4881
4882
4882
<div class="ins">
4883
4883
4884
- 3. *Remarks:* For a type `C`, if `stoppable_callback_for<Callback, stop_token,
4885
- C>` is satisfied, then `stoppable_callback_for<Callback, stop_token, C>` is
4886
- modeled. The exposition-only `callback` member is the associated callback
4887
- function ([stoptoken.concepts] ) of `stop_callback<Callback>` objects.
4884
+ 3. *Remarks:* For a type `C`, if
4885
+ <code><i> stoppable-callback-for</i> <Callback, stop_token, C></code> is
4886
+ satisfied, then <code><i> stoppable-callback-for</i> <Callback, stop_token,
4887
+ C></code> is modeled. The exposition-only `callback` member is the
4888
+ associated callback function ([stoptoken.concepts] ) of
4889
+ `stop_callback<Callback>` objects.
4888
4890
4889
4891
</div>
4890
4892
@@ -5056,7 +5058,7 @@ of Stop tokens <b>[thread.stoptoken]</b>.</span>
5056
5058
5057
5059
#### General <b> [stopsource.inplace.general] </b> #### {#spec-stopsource.inplace.general}
5058
5060
5059
- 1. The class `inplace_stop_source` models `stoppable_source` . Unlike
5061
+ 1. The class `inplace_stop_source` models <i> `stoppable-source` </i> . Unlike
5060
5062
`stop_source`, `inplace_stop_source` does not require dynamic allocation or
5061
5063
reference counting of a shared stop state. Instead, it requires that all
5062
5064
uses of associated `inplace_stop_token` and `inplace_stop_callback`
@@ -5164,11 +5166,13 @@ added above, as a new subclause of Stop tokens <b>[thread.stoptoken]</b>.</span>
5164
5166
template parameter `Callback` that satisfies both `invocable` and
5165
5167
`destructible`.
5166
5168
5167
- 2. *Remarks:* For a type `C`, if `stoppable_callback_for<Callback, inplace_stop_token,
5168
- C>` is satisfied, then `stoppable_callback_for<Callback,
5169
- inplace_stop_token, C>` is modeled. The exposition-only
5170
- <i> `stop-callback`</i> member is the associated callback function
5171
- ([stoptoken.concepts] ) of `inplace_stop_callback<Callback>` objects.
5169
+ 2. *Remarks:* For a type `C`, if
5170
+ <code><i> stoppable-callback-for</i> <Callback, inplace_stop_token,
5171
+ C></code> is satisfied, then
5172
+ <code><i> stoppable-callback-for</i> <Callback, inplace_stop_token,
5173
+ C></code> is modeled. The exposition-only <i> `stop-callback`</i> member is
5174
+ the associated callback function ([stoptoken.concepts] ) of
5175
+ `inplace_stop_callback<Callback>` objects.
5172
5176
5173
5177
Implementations are not permitted to use additional storage, such
5174
5178
as dynamic memory, to store the state necessary for an
@@ -6533,30 +6537,27 @@ namespace std::execution {
6533
6537
template<class Sndr, class Rcvr, class Index>
6534
6538
requires <i> well-formed</i> <<i> env-type</i> , Index, Sndr, Rcvr>
6535
6539
struct <i> basic-receiver</i> { // exposition only
6536
- using <i> tag-type</i> = tag_of_t<Sndr>; // exposition only
6537
6540
using receiver_concept = receiver_t;
6538
6541
6542
+ using <i> tag-type</i> = tag_of_t<Sndr>; // exposition only
6543
+ using <i> state-type</i> = <i> state-type</i> <Sndr, Rcvr>; // exposition only
6544
+ static constexpr const auto& <i> complete</i> = <i> impls-for</i> <<i> tag-type</i> >::<i> complete</i> ; // exposition only
6545
+
6539
6546
template<class... Args>
6540
- requires <i> cpo-callable</i> <<i> impls-for</i> <<i> tag-type</i> >::<i> complete</i> ,
6541
- Index, <i> state-type</i> <Sndr, Rcvr>&, Rcvr&, set_value_t, Args...>
6547
+ requires <i> cpo-callable</i> <<i> complete</i> , Index, <i> state-type</i> &, Rcvr&, set_value_t, Args...>
6542
6548
void set_value(Args&&... args) && noexcept {
6543
- (void) <i> impls-for</i> <<i> tag-type</i> >::<i> complete</i> (
6544
- Index(), <i> op</i> -><i> state</i> , <i> op</i> -><i> rcvr</i> , set_value_t(), std::forward<Args>(args)...);
6549
+ <i> complete</i> (Index(), <i> op</i> -><i> state</i> , <i> op</i> -><i> rcvr</i> , set_value_t(), std::forward<Args>(args)...);
6545
6550
}
6546
6551
6547
6552
template<class Error>
6548
- requires <i> cpo-callable</i> <<i> impls-for</i> <<i> tag-type</i> >::<i> complete</i> ,
6549
- Index, <i> state-type</i> <Sndr, Rcvr>&, Rcvr&, set_error_t, Error>
6553
+ requires <i> cpo-callable</i> <<i> complete</i> , Index, <i> state-type</i> &, Rcvr&, set_error_t, Error>
6550
6554
void set_error(Error&& err) && noexcept {
6551
- (void) <i> impls-for</i> <<i> tag-type</i> >::<i> complete</i> (
6552
- Index(), <i> op</i> -><i> state</i> , <i> op</i> -><i> rcvr</i> , set_error_t(), std::forward<Error>(err));
6555
+ <i> complete</i> (Index(), <i> op</i> -><i> state</i> , <i> op</i> -><i> rcvr</i> , set_error_t(), std::forward<Error>(err));
6553
6556
}
6554
6557
6555
6558
void set_stopped() && noexcept
6556
- requires <i> cpo-callable</i> <<i> impls-for</i> <<i> tag-type</i> >::<i> complete</i> ,
6557
- Index, <i> state-type</i> <Sndr, Rcvr>&, Rcvr&, set_stopped_t> {
6558
- (void) <i> impls-for</i> <<i> tag-type</i> >::<i> complete</i> (
6559
- Index(), <i> op</i> -><i> state</i> , <i> op</i> -><i> rcvr</i> , set_stopped_t());
6559
+ requires <i> cpo-callable</i> <<i> complete</i> , Index, <i> state-type</i> &, Rcvr&, set_stopped_t> {
6560
+ <i> complete</i> (Index(), <i> op</i> -><i> state</i> , <i> op</i> -><i> rcvr</i> , set_stopped_t());
6560
6561
}
6561
6562
6562
6563
auto get_env() const noexcept -> <i> env-type</i> <Index, Sndr, Rcvr> {
0 commit comments