@@ -4135,7 +4135,8 @@ namespace std {
4135
4135
respectively.</ins><del> The last remaining owner of the stop state
4136
4136
automatically releases the resources associated with the stop state.</del>
4137
4137
4138
- 3. A <code> stop<ins> pable</ins> _token</code> can be passed to an operation <del>
4138
+ 3. A<ins> n object of a type that models</ins>
4139
+ <code> stop<ins> pable</ins> _token</code> can be passed to an operation <del>
4139
4140
which</del><ins> that</ins> can either
4140
4141
4141
4142
<div class="numbered" style="counter-set: paragraph 3 list_item 0">
@@ -4146,15 +4147,15 @@ namespace std {
4146
4147
template which</del><ins> that</ins> will be called in the event that a
4147
4148
stop request is made.</div>
4148
4149
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
4150
+ A stop request made via <del> a `stop_source`</del><ins> an object whose type
4151
+ models <i> `stoppable-source`</i></ins> will be visible to all associated
4151
4152
<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).
4153
+ <i> `stoppable-source`</i></ins> objects. Once a stop request has been made
4154
+ it cannot be withdrawn (a subsequent stop request has no effect).
4154
4155
4155
4156
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>
4157
+ whose type models <i> `stoppable-callback-for`</i></ins> are called when a
4158
+ stop request is first made by any associated <del> `stop_source`</del><ins>
4158
4159
<i> `stoppable-source`</i></ins> object.
4159
4160
4160
4161
<span class="ed-note"> The following paragraph is moved to the specification of
@@ -4177,10 +4178,11 @@ the new <i>`stoppable-source`</i> concept.</span>
4177
4178
The last remaining owner of the stop state automatically releases the
4178
4179
resources associated with the stop state.
4179
4180
4180
- 6. The types `inplace_stop_source` and `inplace_stop_token` and the class
4181
- template `inplace_stop_callback` does no dynamic memory allocation of the
4182
- stop state. <span class="wg21note"> They are for use when the lifetimes of
4183
- the associated token and callback objects are known to nest within the
4181
+ 6. An object of type `inplace_stop_source` is the sole owner of its stop state.
4182
+ An object of type `inplace_stop_token` or of a specialization of the class
4183
+ template `inplace_stop_callback` does not participate in ownership of its
4184
+ associated stop state. <span class="wg21note"> They are for use when all uses
4185
+ of the associated token and callback objects are known to nest within the
4184
4186
lifetime of the `inplace_stop_source` object.</span>
4185
4187
4186
4188
</div>
@@ -4233,13 +4235,13 @@ namespace std {
4233
4235
template<class CallbackFn>
4234
4236
class inplace_stop_callback;
4235
4237
4238
+ <span class="ed-note"> Do we need the `::template` here?</span>
4236
4239
template<class T, class CallbackFn>
4237
4240
using stop_callback_for_t = T::template callback_type<CallbackFn>;</div>
4238
4241
}
4239
4242
</pre>
4240
4243
</div>
4241
4244
4242
-
4243
4245
<span class="ed-note"> Insert the following subclause as a new subclause between
4244
4246
Header `<stop_token> ` synopsis <b> [thread.stoptoken.syn] </b> and Class
4245
4247
`stop_token` <b> [stoptoken] </b> .</span>
@@ -4248,13 +4250,8 @@ Header `<stop_token>` synopsis <b>[thread.stoptoken.syn]</b> and Class
4248
4250
4249
4251
### Stop token concepts <b> [stoptoken.concepts] </b> ### {#spec-stoptoken.concepts}
4250
4252
4251
- 1. For a stop token type `Token` and a type `CallbackFn` such that
4252
- <code> invocable<CallbackFn></code> is `true`, if the type
4253
- `stop_callback_for_t<Token, CallbackFn>` is valid, it denotes the type of a
4254
- stop callback to use when registering a callback invocation to be executed
4255
- if a stop request is made on the `stoppable_token`'s associated stop source.
4256
- The exposition-only <i> `stoppable-callback-for`</i> concept checks for a
4257
- callback compatible with a given stop token type.
4253
+ 1. The exposition-only <i> `stoppable-callback-for`</i> concept checks for a
4254
+ callback compatible with a given `Token` type.
4258
4255
4259
4256
<pre highlight="c++">
4260
4257
template<class CallbackFn, class Token, class Initializer = CallbackFn>
@@ -4266,9 +4263,9 @@ Header `<stop_token>` synopsis <b>[thread.stoptoken.syn]</b> and Class
4266
4263
</pre>
4267
4264
4268
4265
2. Let `t` and `u` be distinct, valid objects of type `Token` that reference the
4269
- same logical stop state; let `init` be an object of type
4270
- `Initializer` ; and let `SCB` denote the type `stop_callback_for_t<Token,
4271
- CallbackFn>`.
4266
+ same logical stop state; let `init` be an expression such that
4267
+ `same_as <decltype(init), Initializer> ` is `true` ; and let `SCB` denote the
4268
+ type `stop_callback_for_t<Token, CallbackFn>`.
4272
4269
4273
4270
3. The concept <code><i> stoppable-callback-for</i> <CallbackFn, Token,
4274
4271
Initializer></code> is modeled only if:
@@ -4317,11 +4314,12 @@ Header `<stop_token>` synopsis <b>[thread.stoptoken.syn]</b> and Class
4317
4314
initialization of `cbfn`.</span>
4318
4315
4319
4316
3. Destruction of `scb` shall execute a <dfn export=true>stoppable callback
4320
- deregistration</dfn> as follows:
4317
+ deregistration</dfn> as follows (in order) :
4321
4318
4322
4319
1. If the constructor of `scb` did not register a callback invocation
4323
4320
with `t`'s stop state, then the stoppable callback
4324
- deregistration shall have no effect.
4321
+ deregistration shall have no effect other than destroying `cbfn`
4322
+ if it was constructed.
4325
4323
4326
4324
2. Otherwise, the invocation of `cbfn` shall be removed from
4327
4325
the associated stop state.
@@ -4341,13 +4339,13 @@ Header `<stop_token>` synopsis <b>[thread.stoptoken.syn]</b> and Class
4341
4339
of the invocation of some other callback registered with the same
4342
4340
logical stop state.
4343
4341
4344
- 6. As a final step, the stoppable callback deregistration shall destroy
4342
+ 6. The stoppable callback deregistration shall destroy
4345
4343
`cbfn`.
4346
4344
4347
4345
4. The `stoppable_token` concept checks for the basic interface of a stop token
4348
4346
that is copyable and allows polling to see if stop has been requested and
4349
4347
also whether a stop request is possible. The `unstoppable_token` concept
4350
- checks for a stop token type that does not allow stopping.
4348
+ checks for a `stoppable_token` type that does not allow stopping.
4351
4349
4352
4350
<pre highlight="c++">
4353
4351
template<template<class> class>
@@ -4374,31 +4372,36 @@ Header `<stop_token>` synopsis <b>[thread.stoptoken.syn]</b> and Class
4374
4372
};
4375
4373
</pre>
4376
4374
4377
- 5. The type `Token` models `stoppable_token` only if:
4375
+ 5. An object whose type models `stoppable_token` has at most one associated
4376
+ logical stop state. A `stoppable_token` object with no associated stop
4377
+ state is said to be <dfn export=true>disengaged</dfn> .
4378
+
4379
+ 6. Let `SP` be an evaluation of `t.stop_possible()` that is `false`, and let
4380
+ `SR` be an evaluation of `t.stop_requested()` that is `true`.
4381
+
4382
+ 7. The type `Token` models `stoppable_token` only if:
4378
4383
4379
- 1. An evaluation, `E`, of `t.stop_possible()` is `false`, then
4380
- evaluations of `u.stop_possible()` and `u.stop_requested()` that happen
4381
- after `E` shall evaluate to `false`.
4384
+ 1. Any evaluation of `u.stop_possible()` or `u.stop_requested()`
4385
+ that happens after ([intro.races] ) `SP` is `false`.
4382
4386
4383
- 2. An evaluation, `E`, of `t.stop_requested()` is `true`, then
4384
- evaluations of `u.stop_possible()` and `u.stop_requested()` that happen
4385
- after `E` shall evaluate to `true`.
4387
+ 2. Any evaluation of `u.stop_possible()` or `u.stop_requested()`
4388
+ that happens after `SR` is `true`.
4386
4389
4387
- 3. For any types `CallbackFn` and `Initializer`, if
4390
+ 3. For any types `CallbackFn` and `Initializer` such that
4388
4391
<code><i> stoppable-callback-for</i> <CallbackFn, Token,
4389
- Initializer></code> is satisfied, then
4392
+ Initializer></code> is satisfied,
4390
4393
<code><i> stoppable-callback-for</i> <CallbackFn, Token,
4391
- Initializer></code> shall be modeled.
4394
+ Initializer></code> is modeled.
4395
+
4396
+ 4. If `t` is disengaged, evaluations of `t.stop_possible()` and
4397
+ `t.stop_requested()` are `false`.
4398
+
4399
+ 5. If `t` and `u` reference the same stop state, or if both `t` and `u` are
4400
+ disengaged, `t == u` is `true`; otherwise, it is `false`.
4392
4401
4393
- 4. An object that models `stoppable_token` has at most one associated
4394
- logical stop state. A `stoppable_token` object with no associated stop
4395
- state is said to be <dfn export=true>disengaged</dfn> . For a disengaged
4396
- `stoppable_token` object, `stop_possible` and `stop_requested` shall
4397
- return `false`. If `t` and `u` reference the same stop state, or if both
4398
- `t` and `u` are disengaged, `t == u` shall be `true`; otherwise, it
4399
- shall be `false`.
4402
+ <!-- LWG stopped here on 2024-04-17 -->
4400
4403
4401
- 6 . An object whose type models the exposition-only <i> `stoppable-source`</i>
4404
+ 8 . An object whose type models the exposition-only <i> `stoppable-source`</i>
4402
4405
concept can be queried whether stop has been requested (`stop_requested`)
4403
4406
and whether stop is possible (`stop_possible`). It is a factory for
4404
4407
associated stop tokens (`get_token`), and a stop request can be made on it
0 commit comments