- tmp/tmpev0rvilf/{from.md → to.md} +48 -246
tmp/tmpev0rvilf/{from.md → to.md}
RENAMED
|
@@ -49,13 +49,10 @@ namespace std {
|
|
| 49 |
template<> class promise<void>;
|
| 50 |
|
| 51 |
template<class R>
|
| 52 |
void swap(promise<R>& x, promise<R>& y) noexcept;
|
| 53 |
|
| 54 |
-
template<class R, class Alloc>
|
| 55 |
-
struct uses_allocator<promise<R>, Alloc>;
|
| 56 |
-
|
| 57 |
// [futures.unique.future], class template future
|
| 58 |
template<class R> class future;
|
| 59 |
template<class R> class future<R&>;
|
| 60 |
template<> class future<void>;
|
| 61 |
|
|
@@ -72,14 +69,14 @@ namespace std {
|
|
| 72 |
template<class R, class... ArgTypes>
|
| 73 |
void swap(packaged_task<R(ArgTypes...)>&, packaged_task<R(ArgTypes...)>&) noexcept;
|
| 74 |
|
| 75 |
// [futures.async], function template async
|
| 76 |
template<class F, class... Args>
|
| 77 |
-
|
| 78 |
async(F&& f, Args&&... args);
|
| 79 |
template<class F, class... Args>
|
| 80 |
-
|
| 81 |
async(launch policy, F&& f, Args&&... args);
|
| 82 |
}
|
| 83 |
```
|
| 84 |
|
| 85 |
The `enum` type `launch` is a bitmask type [[bitmask.types]] with
|
|
@@ -177,11 +174,12 @@ waiting function*, otherwise it is a *non-timed waiting function*.
|
|
| 177 |
|
| 178 |
An *asynchronous provider* is an object that provides a result to a
|
| 179 |
shared state. The result of a shared state is set by respective
|
| 180 |
functions on the asynchronous provider.
|
| 181 |
|
| 182 |
-
[*
|
|
|
|
| 183 |
|
| 184 |
The means of setting the result of a shared state is specified in the
|
| 185 |
description of those classes and functions that create such a state
|
| 186 |
object.
|
| 187 |
|
|
@@ -231,11 +229,11 @@ of each of that thread’s objects with thread storage duration
|
|
| 231 |
[[basic.stc.thread]] is sequenced before making that shared state ready.
|
| 232 |
|
| 233 |
Access to the result of the same shared state may conflict
|
| 234 |
[[intro.multithread]].
|
| 235 |
|
| 236 |
-
[*Note
|
| 237 |
state is visible in the objects that reference this state in the sense
|
| 238 |
of data race avoidance [[res.on.data.races]]. For example, concurrent
|
| 239 |
accesses through references returned by `shared_future::get()`
|
| 240 |
[[futures.shared.future]] must either use read-only operations or
|
| 241 |
provide additional synchronization. — *end note*]
|
|
@@ -268,13 +266,10 @@ namespace std {
|
|
| 268 |
|
| 269 |
// setting the result with deferred notification
|
| 270 |
void set_value_at_thread_exit(see below);
|
| 271 |
void set_exception_at_thread_exit(exception_ptr p);
|
| 272 |
};
|
| 273 |
-
|
| 274 |
-
template<class R, class Alloc>
|
| 275 |
-
struct uses_allocator<promise<R>, Alloc>;
|
| 276 |
}
|
| 277 |
```
|
| 278 |
|
| 279 |
For the primary template, `R` shall be an object type that meets the
|
| 280 |
*Cpp17Destructible* requirements.
|
|
@@ -287,19 +282,10 @@ in the argument type of the member functions `set_value` and
|
|
| 287 |
The `set_value`, `set_exception`, `set_value_at_thread_exit`, and
|
| 288 |
`set_exception_at_thread_exit` member functions behave as though they
|
| 289 |
acquire a single mutex associated with the promise object while updating
|
| 290 |
the promise object.
|
| 291 |
|
| 292 |
-
``` cpp
|
| 293 |
-
template<class R, class Alloc>
|
| 294 |
-
struct uses_allocator<promise<R>, Alloc>
|
| 295 |
-
: true_type { };
|
| 296 |
-
```
|
| 297 |
-
|
| 298 |
-
*Preconditions:* `Alloc` meets the *Cpp17Allocator*
|
| 299 |
-
requirements [[allocator.requirements.general]].
|
| 300 |
-
|
| 301 |
``` cpp
|
| 302 |
promise();
|
| 303 |
template<class Allocator>
|
| 304 |
promise(allocator_arg_t, const Allocator& a);
|
| 305 |
```
|
|
@@ -414,11 +400,11 @@ void promise<R&>::set_value_at_thread_exit(R& r);
|
|
| 414 |
void promise<void>::set_value_at_thread_exit();
|
| 415 |
```
|
| 416 |
|
| 417 |
*Effects:* Stores the value `r` in the shared state without making that
|
| 418 |
state ready immediately. Schedules that state to be made ready when the
|
| 419 |
-
current thread exits, after all objects
|
| 420 |
associated with the current thread have been destroyed.
|
| 421 |
|
| 422 |
*Throws:*
|
| 423 |
|
| 424 |
- `future_error` if its shared state already has a stored value or
|
|
@@ -440,12 +426,12 @@ void set_exception_at_thread_exit(exception_ptr p);
|
|
| 440 |
|
| 441 |
*Preconditions:* `p` is not null.
|
| 442 |
|
| 443 |
*Effects:* Stores the exception pointer `p` in the shared state without
|
| 444 |
making that state ready immediately. Schedules that state to be made
|
| 445 |
-
ready when the current thread exits, after all objects
|
| 446 |
-
duration associated with the current thread have been destroyed.
|
| 447 |
|
| 448 |
*Throws:* `future_error` if an error condition occurs.
|
| 449 |
|
| 450 |
*Error conditions:*
|
| 451 |
|
|
@@ -473,11 +459,11 @@ respective function on an object that shares the same shared state.
|
|
| 473 |
|
| 474 |
[*Note 1*: Member functions of `future` do not synchronize with
|
| 475 |
themselves or with member functions of `shared_future`. — *end note*]
|
| 476 |
|
| 477 |
The effect of calling any member function other than the destructor, the
|
| 478 |
-
move
|
| 479 |
which `valid() == false` is undefined.
|
| 480 |
|
| 481 |
[*Note 2*: It is valid to move from a future object for which
|
| 482 |
`valid() == false`. — *end note*]
|
| 483 |
|
|
@@ -672,11 +658,11 @@ object that shares the same shared state.
|
|
| 672 |
|
| 673 |
[*Note 1*: Member functions of `shared_future` do not synchronize with
|
| 674 |
themselves, but they synchronize with the shared state. — *end note*]
|
| 675 |
|
| 676 |
The effect of calling any member function other than the destructor, the
|
| 677 |
-
move
|
| 678 |
a `shared_future` object for which `valid() == false` is undefined.
|
| 679 |
|
| 680 |
[*Note 2*: It is valid to copy or move from a `shared_future` object
|
| 681 |
for which `valid()` is `false`. — *end note*]
|
| 682 |
|
|
@@ -881,14 +867,14 @@ The function template `async` provides a mechanism to launch a function
|
|
| 881 |
potentially in a new thread and provides the result of the function in a
|
| 882 |
`future` object with which it shares a shared state.
|
| 883 |
|
| 884 |
``` cpp
|
| 885 |
template<class F, class... Args>
|
| 886 |
-
|
| 887 |
async(F&& f, Args&&... args);
|
| 888 |
template<class F, class... Args>
|
| 889 |
-
|
| 890 |
async(launch policy, F&& f, Args&&... args);
|
| 891 |
```
|
| 892 |
|
| 893 |
*Mandates:* The following are all `true`:
|
| 894 |
|
|
@@ -1005,10 +991,12 @@ namespace std {
|
|
| 1005 |
public:
|
| 1006 |
// construction and destruction
|
| 1007 |
packaged_task() noexcept;
|
| 1008 |
template<class F>
|
| 1009 |
explicit packaged_task(F&& f);
|
|
|
|
|
|
|
| 1010 |
~packaged_task();
|
| 1011 |
|
| 1012 |
// no copy
|
| 1013 |
packaged_task(const packaged_task&) = delete;
|
| 1014 |
packaged_task& operator=(const packaged_task&) = delete;
|
|
@@ -1048,24 +1036,37 @@ packaged_task() noexcept;
|
|
| 1048 |
``` cpp
|
| 1049 |
template<class F>
|
| 1050 |
explicit packaged_task(F&& f);
|
| 1051 |
```
|
| 1052 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1053 |
*Constraints:* `remove_cvref_t<F>` is not the same type as
|
| 1054 |
`packaged_task<R(ArgTypes...)>`.
|
| 1055 |
|
| 1056 |
-
*Mandates:* `is_invocable_r_v<R, F&, ArgTypes...>` is `true`.
|
| 1057 |
|
| 1058 |
-
*Preconditions:*
|
| 1059 |
-
|
| 1060 |
|
| 1061 |
-
*Effects:*
|
| 1062 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1063 |
|
| 1064 |
-
*Throws:* Any exceptions thrown by the
|
| 1065 |
-
|
| 1066 |
-
|
| 1067 |
|
| 1068 |
``` cpp
|
| 1069 |
template<class F> packaged_task(F) -> packaged_task<see below>;
|
| 1070 |
```
|
| 1071 |
|
|
@@ -1175,11 +1176,11 @@ where `f` is the stored task and `t`₁`, t`₂`, `…`, t`$_N$ are the values
|
|
| 1175 |
in `args...`. If the task returns normally, the return value is stored
|
| 1176 |
as the asynchronous result in the shared state of `*this`, otherwise the
|
| 1177 |
exception thrown by the task is stored. In either case, this is done
|
| 1178 |
without making that state ready [[futures.state]] immediately. Schedules
|
| 1179 |
the shared state to be made ready when the current thread exits, after
|
| 1180 |
-
all objects
|
| 1181 |
thread have been destroyed.
|
| 1182 |
|
| 1183 |
*Throws:* `future_error` if an error condition occurs.
|
| 1184 |
|
| 1185 |
*Error conditions:*
|
|
@@ -1190,21 +1191,28 @@ thread have been destroyed.
|
|
| 1190 |
|
| 1191 |
``` cpp
|
| 1192 |
void reset();
|
| 1193 |
```
|
| 1194 |
|
| 1195 |
-
*Effects:*
|
| 1196 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1197 |
|
| 1198 |
[*Note 2*: This constructs a new shared state for `*this`. The old
|
| 1199 |
state is abandoned [[futures.state]]. — *end note*]
|
| 1200 |
|
| 1201 |
*Throws:*
|
| 1202 |
|
| 1203 |
-
-
|
| 1204 |
-
- Any exception thrown by the move constructor of the task stored in the
|
| 1205 |
-
shared state.
|
| 1206 |
- `future_error` with an error condition of `no_state` if `*this` has no
|
| 1207 |
shared state.
|
| 1208 |
|
| 1209 |
#### Globals <a id="futures.task.nonmembers">[[futures.task.nonmembers]]</a>
|
| 1210 |
|
|
@@ -1213,211 +1221,5 @@ template<class R, class... ArgTypes>
|
|
| 1213 |
void swap(packaged_task<R(ArgTypes...)>& x, packaged_task<R(ArgTypes...)>& y) noexcept;
|
| 1214 |
```
|
| 1215 |
|
| 1216 |
*Effects:* As if by `x.swap(y)`.
|
| 1217 |
|
| 1218 |
-
<!-- Link reference definitions -->
|
| 1219 |
-
[alg.sorting]: algorithms.md#alg.sorting
|
| 1220 |
-
[allocator.requirements.general]: library.md#allocator.requirements.general
|
| 1221 |
-
[atomic.types.int.comp]: #atomic.types.int.comp
|
| 1222 |
-
[atomic.types.pointer.comp]: #atomic.types.pointer.comp
|
| 1223 |
-
[atomics]: #atomics
|
| 1224 |
-
[atomics.alias]: #atomics.alias
|
| 1225 |
-
[atomics.fences]: #atomics.fences
|
| 1226 |
-
[atomics.flag]: #atomics.flag
|
| 1227 |
-
[atomics.general]: #atomics.general
|
| 1228 |
-
[atomics.lockfree]: #atomics.lockfree
|
| 1229 |
-
[atomics.nonmembers]: #atomics.nonmembers
|
| 1230 |
-
[atomics.order]: #atomics.order
|
| 1231 |
-
[atomics.ref.float]: #atomics.ref.float
|
| 1232 |
-
[atomics.ref.generic]: #atomics.ref.generic
|
| 1233 |
-
[atomics.ref.generic.general]: #atomics.ref.generic.general
|
| 1234 |
-
[atomics.ref.int]: #atomics.ref.int
|
| 1235 |
-
[atomics.ref.memop]: #atomics.ref.memop
|
| 1236 |
-
[atomics.ref.ops]: #atomics.ref.ops
|
| 1237 |
-
[atomics.ref.pointer]: #atomics.ref.pointer
|
| 1238 |
-
[atomics.syn]: #atomics.syn
|
| 1239 |
-
[atomics.types.float]: #atomics.types.float
|
| 1240 |
-
[atomics.types.generic]: #atomics.types.generic
|
| 1241 |
-
[atomics.types.generic.general]: #atomics.types.generic.general
|
| 1242 |
-
[atomics.types.int]: #atomics.types.int
|
| 1243 |
-
[atomics.types.memop]: #atomics.types.memop
|
| 1244 |
-
[atomics.types.operations]: #atomics.types.operations
|
| 1245 |
-
[atomics.types.pointer]: #atomics.types.pointer
|
| 1246 |
-
[atomics.wait]: #atomics.wait
|
| 1247 |
-
[barrier.syn]: #barrier.syn
|
| 1248 |
-
[basic.align]: basic.md#basic.align
|
| 1249 |
-
[basic.fundamental]: basic.md#basic.fundamental
|
| 1250 |
-
[basic.life]: basic.md#basic.life
|
| 1251 |
-
[basic.stc.thread]: basic.md#basic.stc.thread
|
| 1252 |
-
[bitmask.types]: library.md#bitmask.types
|
| 1253 |
-
[cfenv]: numerics.md#cfenv
|
| 1254 |
-
[class.prop]: class.md#class.prop
|
| 1255 |
-
[compliance]: library.md#compliance
|
| 1256 |
-
[concept.booleantestable]: concepts.md#concept.booleantestable
|
| 1257 |
-
[condition.variable.syn]: #condition.variable.syn
|
| 1258 |
-
[conv.rval]: expr.md#conv.rval
|
| 1259 |
-
[cpp17.defaultconstructible]: #cpp17.defaultconstructible
|
| 1260 |
-
[cpp17.destructible]: #cpp17.destructible
|
| 1261 |
-
[cpp17.moveassignable]: #cpp17.moveassignable
|
| 1262 |
-
[cpp17.moveconstructible]: #cpp17.moveconstructible
|
| 1263 |
-
[defns.block]: intro.md#defns.block
|
| 1264 |
-
[except.terminate]: except.md#except.terminate
|
| 1265 |
-
[expr.pre]: expr.md#expr.pre
|
| 1266 |
-
[format.string.std]: utilities.md#format.string.std
|
| 1267 |
-
[func.invoke]: utilities.md#func.invoke
|
| 1268 |
-
[func.require]: utilities.md#func.require
|
| 1269 |
-
[function.objects]: utilities.md#function.objects
|
| 1270 |
-
[future.syn]: #future.syn
|
| 1271 |
-
[futures]: #futures
|
| 1272 |
-
[futures.async]: #futures.async
|
| 1273 |
-
[futures.errors]: #futures.errors
|
| 1274 |
-
[futures.future.error]: #futures.future.error
|
| 1275 |
-
[futures.overview]: #futures.overview
|
| 1276 |
-
[futures.promise]: #futures.promise
|
| 1277 |
-
[futures.shared.future]: #futures.shared.future
|
| 1278 |
-
[futures.state]: #futures.state
|
| 1279 |
-
[futures.task]: #futures.task
|
| 1280 |
-
[futures.task.general]: #futures.task.general
|
| 1281 |
-
[futures.task.members]: #futures.task.members
|
| 1282 |
-
[futures.task.nonmembers]: #futures.task.nonmembers
|
| 1283 |
-
[futures.unique.future]: #futures.unique.future
|
| 1284 |
-
[intro.multithread]: basic.md#intro.multithread
|
| 1285 |
-
[intro.progress]: basic.md#intro.progress
|
| 1286 |
-
[intro.races]: basic.md#intro.races
|
| 1287 |
-
[latch.syn]: #latch.syn
|
| 1288 |
-
[limits.syn]: support.md#limits.syn
|
| 1289 |
-
[mutex.syn]: #mutex.syn
|
| 1290 |
-
[res.on.data.races]: library.md#res.on.data.races
|
| 1291 |
-
[res.on.exception.handling]: library.md#res.on.exception.handling
|
| 1292 |
-
[semaphore.syn]: #semaphore.syn
|
| 1293 |
-
[shared.mutex.syn]: #shared.mutex.syn
|
| 1294 |
-
[stdatomic.h.syn]: #stdatomic.h.syn
|
| 1295 |
-
[stopcallback]: #stopcallback
|
| 1296 |
-
[stopcallback.cons]: #stopcallback.cons
|
| 1297 |
-
[stopcallback.general]: #stopcallback.general
|
| 1298 |
-
[stopsource]: #stopsource
|
| 1299 |
-
[stopsource.cons]: #stopsource.cons
|
| 1300 |
-
[stopsource.general]: #stopsource.general
|
| 1301 |
-
[stopsource.mem]: #stopsource.mem
|
| 1302 |
-
[stopsource.nonmembers]: #stopsource.nonmembers
|
| 1303 |
-
[stoptoken]: #stoptoken
|
| 1304 |
-
[stoptoken.cons]: #stoptoken.cons
|
| 1305 |
-
[stoptoken.general]: #stoptoken.general
|
| 1306 |
-
[stoptoken.mem]: #stoptoken.mem
|
| 1307 |
-
[stoptoken.nonmembers]: #stoptoken.nonmembers
|
| 1308 |
-
[syserr]: diagnostics.md#syserr
|
| 1309 |
-
[syserr.syserr]: diagnostics.md#syserr.syserr
|
| 1310 |
-
[term.padding.bits]: basic.md#term.padding.bits
|
| 1311 |
-
[term.unevaluated.operand]: expr.md#term.unevaluated.operand
|
| 1312 |
-
[thread]: #thread
|
| 1313 |
-
[thread.barrier]: #thread.barrier
|
| 1314 |
-
[thread.barrier.class]: #thread.barrier.class
|
| 1315 |
-
[thread.barrier.general]: #thread.barrier.general
|
| 1316 |
-
[thread.condition]: #thread.condition
|
| 1317 |
-
[thread.condition.condvar]: #thread.condition.condvar
|
| 1318 |
-
[thread.condition.condvarany]: #thread.condition.condvarany
|
| 1319 |
-
[thread.condition.condvarany.general]: #thread.condition.condvarany.general
|
| 1320 |
-
[thread.condition.general]: #thread.condition.general
|
| 1321 |
-
[thread.condition.nonmember]: #thread.condition.nonmember
|
| 1322 |
-
[thread.condvarany.intwait]: #thread.condvarany.intwait
|
| 1323 |
-
[thread.condvarany.wait]: #thread.condvarany.wait
|
| 1324 |
-
[thread.coord]: #thread.coord
|
| 1325 |
-
[thread.coord.general]: #thread.coord.general
|
| 1326 |
-
[thread.general]: #thread.general
|
| 1327 |
-
[thread.jthread.class]: #thread.jthread.class
|
| 1328 |
-
[thread.jthread.class.general]: #thread.jthread.class.general
|
| 1329 |
-
[thread.jthread.cons]: #thread.jthread.cons
|
| 1330 |
-
[thread.jthread.mem]: #thread.jthread.mem
|
| 1331 |
-
[thread.jthread.special]: #thread.jthread.special
|
| 1332 |
-
[thread.jthread.static]: #thread.jthread.static
|
| 1333 |
-
[thread.jthread.stop]: #thread.jthread.stop
|
| 1334 |
-
[thread.latch]: #thread.latch
|
| 1335 |
-
[thread.latch.class]: #thread.latch.class
|
| 1336 |
-
[thread.latch.general]: #thread.latch.general
|
| 1337 |
-
[thread.lock]: #thread.lock
|
| 1338 |
-
[thread.lock.algorithm]: #thread.lock.algorithm
|
| 1339 |
-
[thread.lock.general]: #thread.lock.general
|
| 1340 |
-
[thread.lock.guard]: #thread.lock.guard
|
| 1341 |
-
[thread.lock.scoped]: #thread.lock.scoped
|
| 1342 |
-
[thread.lock.shared]: #thread.lock.shared
|
| 1343 |
-
[thread.lock.shared.cons]: #thread.lock.shared.cons
|
| 1344 |
-
[thread.lock.shared.general]: #thread.lock.shared.general
|
| 1345 |
-
[thread.lock.shared.locking]: #thread.lock.shared.locking
|
| 1346 |
-
[thread.lock.shared.mod]: #thread.lock.shared.mod
|
| 1347 |
-
[thread.lock.shared.obs]: #thread.lock.shared.obs
|
| 1348 |
-
[thread.lock.unique]: #thread.lock.unique
|
| 1349 |
-
[thread.lock.unique.cons]: #thread.lock.unique.cons
|
| 1350 |
-
[thread.lock.unique.general]: #thread.lock.unique.general
|
| 1351 |
-
[thread.lock.unique.locking]: #thread.lock.unique.locking
|
| 1352 |
-
[thread.lock.unique.mod]: #thread.lock.unique.mod
|
| 1353 |
-
[thread.lock.unique.obs]: #thread.lock.unique.obs
|
| 1354 |
-
[thread.mutex]: #thread.mutex
|
| 1355 |
-
[thread.mutex.class]: #thread.mutex.class
|
| 1356 |
-
[thread.mutex.general]: #thread.mutex.general
|
| 1357 |
-
[thread.mutex.recursive]: #thread.mutex.recursive
|
| 1358 |
-
[thread.mutex.requirements]: #thread.mutex.requirements
|
| 1359 |
-
[thread.mutex.requirements.general]: #thread.mutex.requirements.general
|
| 1360 |
-
[thread.mutex.requirements.mutex]: #thread.mutex.requirements.mutex
|
| 1361 |
-
[thread.mutex.requirements.mutex.general]: #thread.mutex.requirements.mutex.general
|
| 1362 |
-
[thread.once]: #thread.once
|
| 1363 |
-
[thread.once.callonce]: #thread.once.callonce
|
| 1364 |
-
[thread.once.onceflag]: #thread.once.onceflag
|
| 1365 |
-
[thread.req]: #thread.req
|
| 1366 |
-
[thread.req.exception]: #thread.req.exception
|
| 1367 |
-
[thread.req.lockable]: #thread.req.lockable
|
| 1368 |
-
[thread.req.lockable.basic]: #thread.req.lockable.basic
|
| 1369 |
-
[thread.req.lockable.general]: #thread.req.lockable.general
|
| 1370 |
-
[thread.req.lockable.req]: #thread.req.lockable.req
|
| 1371 |
-
[thread.req.lockable.shared]: #thread.req.lockable.shared
|
| 1372 |
-
[thread.req.lockable.shared.timed]: #thread.req.lockable.shared.timed
|
| 1373 |
-
[thread.req.lockable.timed]: #thread.req.lockable.timed
|
| 1374 |
-
[thread.req.native]: #thread.req.native
|
| 1375 |
-
[thread.req.paramname]: #thread.req.paramname
|
| 1376 |
-
[thread.req.timing]: #thread.req.timing
|
| 1377 |
-
[thread.sema]: #thread.sema
|
| 1378 |
-
[thread.sema.cnt]: #thread.sema.cnt
|
| 1379 |
-
[thread.sema.general]: #thread.sema.general
|
| 1380 |
-
[thread.sharedmutex.class]: #thread.sharedmutex.class
|
| 1381 |
-
[thread.sharedmutex.requirements]: #thread.sharedmutex.requirements
|
| 1382 |
-
[thread.sharedmutex.requirements.general]: #thread.sharedmutex.requirements.general
|
| 1383 |
-
[thread.sharedtimedmutex.class]: #thread.sharedtimedmutex.class
|
| 1384 |
-
[thread.sharedtimedmutex.requirements]: #thread.sharedtimedmutex.requirements
|
| 1385 |
-
[thread.sharedtimedmutex.requirements.general]: #thread.sharedtimedmutex.requirements.general
|
| 1386 |
-
[thread.stoptoken]: #thread.stoptoken
|
| 1387 |
-
[thread.stoptoken.intro]: #thread.stoptoken.intro
|
| 1388 |
-
[thread.stoptoken.syn]: #thread.stoptoken.syn
|
| 1389 |
-
[thread.summary]: #thread.summary
|
| 1390 |
-
[thread.syn]: #thread.syn
|
| 1391 |
-
[thread.thread.algorithm]: #thread.thread.algorithm
|
| 1392 |
-
[thread.thread.assign]: #thread.thread.assign
|
| 1393 |
-
[thread.thread.class]: #thread.thread.class
|
| 1394 |
-
[thread.thread.class.general]: #thread.thread.class.general
|
| 1395 |
-
[thread.thread.constr]: #thread.thread.constr
|
| 1396 |
-
[thread.thread.destr]: #thread.thread.destr
|
| 1397 |
-
[thread.thread.id]: #thread.thread.id
|
| 1398 |
-
[thread.thread.member]: #thread.thread.member
|
| 1399 |
-
[thread.thread.static]: #thread.thread.static
|
| 1400 |
-
[thread.thread.this]: #thread.thread.this
|
| 1401 |
-
[thread.threads]: #thread.threads
|
| 1402 |
-
[thread.threads.general]: #thread.threads.general
|
| 1403 |
-
[thread.timedmutex.class]: #thread.timedmutex.class
|
| 1404 |
-
[thread.timedmutex.recursive]: #thread.timedmutex.recursive
|
| 1405 |
-
[thread.timedmutex.requirements]: #thread.timedmutex.requirements
|
| 1406 |
-
[thread.timedmutex.requirements.general]: #thread.timedmutex.requirements.general
|
| 1407 |
-
[time]: time.md#time
|
| 1408 |
-
[time.clock]: time.md#time.clock
|
| 1409 |
-
[time.clock.req]: time.md#time.clock.req
|
| 1410 |
-
[time.duration]: time.md#time.duration
|
| 1411 |
-
[time.point]: time.md#time.point
|
| 1412 |
-
[unord.hash]: utilities.md#unord.hash
|
| 1413 |
-
[util.sharedptr]: mem.md#util.sharedptr
|
| 1414 |
-
[util.smartptr.atomic]: #util.smartptr.atomic
|
| 1415 |
-
[util.smartptr.atomic.general]: #util.smartptr.atomic.general
|
| 1416 |
-
[util.smartptr.atomic.shared]: #util.smartptr.atomic.shared
|
| 1417 |
-
[util.smartptr.atomic.weak]: #util.smartptr.atomic.weak
|
| 1418 |
-
|
| 1419 |
-
[^1]: Implementations for which standard time units are meaningful will
|
| 1420 |
-
typically have a steady clock within their hardware implementation.
|
| 1421 |
-
|
| 1422 |
-
[^2]: That is, atomic operations on the same memory location via two
|
| 1423 |
-
different addresses will communicate atomically.
|
|
|
|
| 49 |
template<> class promise<void>;
|
| 50 |
|
| 51 |
template<class R>
|
| 52 |
void swap(promise<R>& x, promise<R>& y) noexcept;
|
| 53 |
|
|
|
|
|
|
|
|
|
|
| 54 |
// [futures.unique.future], class template future
|
| 55 |
template<class R> class future;
|
| 56 |
template<class R> class future<R&>;
|
| 57 |
template<> class future<void>;
|
| 58 |
|
|
|
|
| 69 |
template<class R, class... ArgTypes>
|
| 70 |
void swap(packaged_task<R(ArgTypes...)>&, packaged_task<R(ArgTypes...)>&) noexcept;
|
| 71 |
|
| 72 |
// [futures.async], function template async
|
| 73 |
template<class F, class... Args>
|
| 74 |
+
future<invoke_result_t<decay_t<F>, decay_t<Args>...>>
|
| 75 |
async(F&& f, Args&&... args);
|
| 76 |
template<class F, class... Args>
|
| 77 |
+
future<invoke_result_t<decay_t<F>, decay_t<Args>...>>
|
| 78 |
async(launch policy, F&& f, Args&&... args);
|
| 79 |
}
|
| 80 |
```
|
| 81 |
|
| 82 |
The `enum` type `launch` is a bitmask type [[bitmask.types]] with
|
|
|
|
| 174 |
|
| 175 |
An *asynchronous provider* is an object that provides a result to a
|
| 176 |
shared state. The result of a shared state is set by respective
|
| 177 |
functions on the asynchronous provider.
|
| 178 |
|
| 179 |
+
[*Example 1*: Promises and tasks are examples of asynchronous
|
| 180 |
+
providers. — *end example*]
|
| 181 |
|
| 182 |
The means of setting the result of a shared state is specified in the
|
| 183 |
description of those classes and functions that create such a state
|
| 184 |
object.
|
| 185 |
|
|
|
|
| 229 |
[[basic.stc.thread]] is sequenced before making that shared state ready.
|
| 230 |
|
| 231 |
Access to the result of the same shared state may conflict
|
| 232 |
[[intro.multithread]].
|
| 233 |
|
| 234 |
+
[*Note 3*: This explicitly specifies that the result of the shared
|
| 235 |
state is visible in the objects that reference this state in the sense
|
| 236 |
of data race avoidance [[res.on.data.races]]. For example, concurrent
|
| 237 |
accesses through references returned by `shared_future::get()`
|
| 238 |
[[futures.shared.future]] must either use read-only operations or
|
| 239 |
provide additional synchronization. — *end note*]
|
|
|
|
| 266 |
|
| 267 |
// setting the result with deferred notification
|
| 268 |
void set_value_at_thread_exit(see below);
|
| 269 |
void set_exception_at_thread_exit(exception_ptr p);
|
| 270 |
};
|
|
|
|
|
|
|
|
|
|
| 271 |
}
|
| 272 |
```
|
| 273 |
|
| 274 |
For the primary template, `R` shall be an object type that meets the
|
| 275 |
*Cpp17Destructible* requirements.
|
|
|
|
| 282 |
The `set_value`, `set_exception`, `set_value_at_thread_exit`, and
|
| 283 |
`set_exception_at_thread_exit` member functions behave as though they
|
| 284 |
acquire a single mutex associated with the promise object while updating
|
| 285 |
the promise object.
|
| 286 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 287 |
``` cpp
|
| 288 |
promise();
|
| 289 |
template<class Allocator>
|
| 290 |
promise(allocator_arg_t, const Allocator& a);
|
| 291 |
```
|
|
|
|
| 400 |
void promise<void>::set_value_at_thread_exit();
|
| 401 |
```
|
| 402 |
|
| 403 |
*Effects:* Stores the value `r` in the shared state without making that
|
| 404 |
state ready immediately. Schedules that state to be made ready when the
|
| 405 |
+
current thread exits, after all objects with thread storage duration
|
| 406 |
associated with the current thread have been destroyed.
|
| 407 |
|
| 408 |
*Throws:*
|
| 409 |
|
| 410 |
- `future_error` if its shared state already has a stored value or
|
|
|
|
| 426 |
|
| 427 |
*Preconditions:* `p` is not null.
|
| 428 |
|
| 429 |
*Effects:* Stores the exception pointer `p` in the shared state without
|
| 430 |
making that state ready immediately. Schedules that state to be made
|
| 431 |
+
ready when the current thread exits, after all objects with thread
|
| 432 |
+
storage duration associated with the current thread have been destroyed.
|
| 433 |
|
| 434 |
*Throws:* `future_error` if an error condition occurs.
|
| 435 |
|
| 436 |
*Error conditions:*
|
| 437 |
|
|
|
|
| 459 |
|
| 460 |
[*Note 1*: Member functions of `future` do not synchronize with
|
| 461 |
themselves or with member functions of `shared_future`. — *end note*]
|
| 462 |
|
| 463 |
The effect of calling any member function other than the destructor, the
|
| 464 |
+
move assignment operator, `share`, or `valid` on a `future` object for
|
| 465 |
which `valid() == false` is undefined.
|
| 466 |
|
| 467 |
[*Note 2*: It is valid to move from a future object for which
|
| 468 |
`valid() == false`. — *end note*]
|
| 469 |
|
|
|
|
| 658 |
|
| 659 |
[*Note 1*: Member functions of `shared_future` do not synchronize with
|
| 660 |
themselves, but they synchronize with the shared state. — *end note*]
|
| 661 |
|
| 662 |
The effect of calling any member function other than the destructor, the
|
| 663 |
+
move assignment operator, the copy assignment operator, or `valid()` on
|
| 664 |
a `shared_future` object for which `valid() == false` is undefined.
|
| 665 |
|
| 666 |
[*Note 2*: It is valid to copy or move from a `shared_future` object
|
| 667 |
for which `valid()` is `false`. — *end note*]
|
| 668 |
|
|
|
|
| 867 |
potentially in a new thread and provides the result of the function in a
|
| 868 |
`future` object with which it shares a shared state.
|
| 869 |
|
| 870 |
``` cpp
|
| 871 |
template<class F, class... Args>
|
| 872 |
+
future<invoke_result_t<decay_t<F>, decay_t<Args>...>>
|
| 873 |
async(F&& f, Args&&... args);
|
| 874 |
template<class F, class... Args>
|
| 875 |
+
future<invoke_result_t<decay_t<F>, decay_t<Args>...>>
|
| 876 |
async(launch policy, F&& f, Args&&... args);
|
| 877 |
```
|
| 878 |
|
| 879 |
*Mandates:* The following are all `true`:
|
| 880 |
|
|
|
|
| 991 |
public:
|
| 992 |
// construction and destruction
|
| 993 |
packaged_task() noexcept;
|
| 994 |
template<class F>
|
| 995 |
explicit packaged_task(F&& f);
|
| 996 |
+
template<class F, class Allocator>
|
| 997 |
+
explicit packaged_task(allocator_arg_t, const Allocator& a, F&& f);
|
| 998 |
~packaged_task();
|
| 999 |
|
| 1000 |
// no copy
|
| 1001 |
packaged_task(const packaged_task&) = delete;
|
| 1002 |
packaged_task& operator=(const packaged_task&) = delete;
|
|
|
|
| 1036 |
``` cpp
|
| 1037 |
template<class F>
|
| 1038 |
explicit packaged_task(F&& f);
|
| 1039 |
```
|
| 1040 |
|
| 1041 |
+
*Effects:* Equivalent to
|
| 1042 |
+
`packaged_task(allocator_arg, allocator<int>(), std::forward<F>(f))`.
|
| 1043 |
+
|
| 1044 |
+
``` cpp
|
| 1045 |
+
template<class F, class Allocator>
|
| 1046 |
+
explicit packaged_task(allocator_arg_t, const Allocator& a, F&& f);
|
| 1047 |
+
```
|
| 1048 |
+
|
| 1049 |
*Constraints:* `remove_cvref_t<F>` is not the same type as
|
| 1050 |
`packaged_task<R(ArgTypes...)>`.
|
| 1051 |
|
| 1052 |
+
*Mandates:* `is_invocable_r_v<R, decay_t<F>&, ArgTypes...>` is `true`.
|
| 1053 |
|
| 1054 |
+
*Preconditions:* `Allocator` meets the *Cpp17Allocator*
|
| 1055 |
+
requirements [[allocator.requirements.general]].
|
| 1056 |
|
| 1057 |
+
*Effects:* Let `A2` be
|
| 1058 |
+
`allocator_traits<Allocator>::rebind_alloc<`*`unspecified`*`>` and let
|
| 1059 |
+
`a2` be an object of type `A2` initialized with `A2(a)`. Constructs a
|
| 1060 |
+
new `packaged_task` object with a stored task of type `decay_t<F>` and a
|
| 1061 |
+
shared state. Initializes the object’s stored task with
|
| 1062 |
+
`std::forward<F>(f)`. Uses `a2` to allocate storage for the shared state
|
| 1063 |
+
and stores a copy of `a2` in the shared state.
|
| 1064 |
|
| 1065 |
+
*Throws:* Any exceptions thrown by the initialization of the stored
|
| 1066 |
+
task. If storage for the shared state cannot be allocated, any exception
|
| 1067 |
+
thrown by `A2::allocate`.
|
| 1068 |
|
| 1069 |
``` cpp
|
| 1070 |
template<class F> packaged_task(F) -> packaged_task<see below>;
|
| 1071 |
```
|
| 1072 |
|
|
|
|
| 1176 |
in `args...`. If the task returns normally, the return value is stored
|
| 1177 |
as the asynchronous result in the shared state of `*this`, otherwise the
|
| 1178 |
exception thrown by the task is stored. In either case, this is done
|
| 1179 |
without making that state ready [[futures.state]] immediately. Schedules
|
| 1180 |
the shared state to be made ready when the current thread exits, after
|
| 1181 |
+
all objects with thread storage duration associated with the current
|
| 1182 |
thread have been destroyed.
|
| 1183 |
|
| 1184 |
*Throws:* `future_error` if an error condition occurs.
|
| 1185 |
|
| 1186 |
*Error conditions:*
|
|
|
|
| 1191 |
|
| 1192 |
``` cpp
|
| 1193 |
void reset();
|
| 1194 |
```
|
| 1195 |
|
| 1196 |
+
*Effects:* Equivalent to:
|
| 1197 |
+
|
| 1198 |
+
``` cpp
|
| 1199 |
+
if (!valid()) {
|
| 1200 |
+
throw future_error(future_errc::no_state);
|
| 1201 |
+
}
|
| 1202 |
+
*this = packaged_task(allocator_arg, a, std::move(f));
|
| 1203 |
+
```
|
| 1204 |
+
|
| 1205 |
+
where `f` is the task stored in `*this` and `a` is the allocator stored
|
| 1206 |
+
in the shared state.
|
| 1207 |
|
| 1208 |
[*Note 2*: This constructs a new shared state for `*this`. The old
|
| 1209 |
state is abandoned [[futures.state]]. — *end note*]
|
| 1210 |
|
| 1211 |
*Throws:*
|
| 1212 |
|
| 1213 |
+
- Any exception thrown by the `packaged_task` constructor.
|
|
|
|
|
|
|
| 1214 |
- `future_error` with an error condition of `no_state` if `*this` has no
|
| 1215 |
shared state.
|
| 1216 |
|
| 1217 |
#### Globals <a id="futures.task.nonmembers">[[futures.task.nonmembers]]</a>
|
| 1218 |
|
|
|
|
| 1221 |
void swap(packaged_task<R(ArgTypes...)>& x, packaged_task<R(ArgTypes...)>& y) noexcept;
|
| 1222 |
```
|
| 1223 |
|
| 1224 |
*Effects:* As if by `x.swap(y)`.
|
| 1225 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|