From Jason Turner

[futures]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpushj7csb/{from.md → to.md} +201 -104
tmp/tmpushj7csb/{from.md → to.md} RENAMED
@@ -13,61 +13,68 @@ well. — *end note*]
13
  ### Header `<future>` synopsis <a id="future.syn">[[future.syn]]</a>
14
 
15
  ``` cpp
16
  namespace std {
17
  enum class future_errc {
18
- broken_promise = implementation-defined,
19
- future_already_retrieved = implementation-defined,
20
- promise_already_satisfied = implementation-defined,
21
- no_state = implementation-defined
22
  };
23
 
24
  enum class launch : unspecified{} {
25
  async = unspecified{},
26
  deferred = unspecified{},
27
- implementation-defined
28
  };
29
 
30
  enum class future_status {
31
  ready,
32
  timeout,
33
  deferred
34
  };
35
 
 
36
  template<> struct is_error_code_enum<future_errc> : public true_type { };
37
  error_code make_error_code(future_errc e) noexcept;
38
  error_condition make_error_condition(future_errc e) noexcept;
39
 
40
  const error_category& future_category() noexcept;
41
 
 
42
  class future_error;
43
 
 
44
  template<class R> class promise;
45
  template<class R> class promise<R&>;
46
  template<> class promise<void>;
47
 
48
  template<class R>
49
  void swap(promise<R>& x, promise<R>& y) noexcept;
50
 
51
  template<class R, class Alloc>
52
  struct uses_allocator<promise<R>, Alloc>;
53
 
 
54
  template<class R> class future;
55
  template<class R> class future<R&>;
56
  template<> class future<void>;
57
 
 
58
  template<class R> class shared_future;
59
  template<class R> class shared_future<R&>;
60
  template<> class shared_future<void>;
61
 
 
62
  template<class> class packaged_task; // not defined
63
  template<class R, class... ArgTypes>
64
  class packaged_task<R(ArgTypes...)>;
65
 
66
  template<class R, class... ArgTypes>
67
  void swap(packaged_task<R(ArgTypes...)>&, packaged_task<R(ArgTypes...)>&) noexcept;
68
 
 
69
  template<class F, class... Args>
70
  [[nodiscard]] future<invoke_result_t<decay_t<F>, decay_t<Args>...>>
71
  async(F&& f, Args&&... args);
72
  template<class F, class... Args>
73
  [[nodiscard]] future<invoke_result_t<decay_t<F>, decay_t<Args>...>>
@@ -93,13 +100,14 @@ const error_category& future_category() noexcept;
93
  ```
94
 
95
  *Returns:* A reference to an object of a type derived from class
96
  `error_category`.
97
 
98
- The object’s `default_error_condition` and equivalent virtual functions
99
- shall behave as specified for the class `error_category`. The object’s
100
- `name` virtual function returns a pointer to the string `"future"`.
 
101
 
102
  ``` cpp
103
  error_code make_error_code(future_errc e) noexcept;
104
  ```
105
 
@@ -151,11 +159,11 @@ const char* what() const noexcept;
151
  Many of the classes introduced in subclause  [[futures]] use some state
152
  to communicate results. This *shared state* consists of some state
153
  information and some (possibly not yet evaluated) *result*, which can be
154
  a (possibly void) value or an exception.
155
 
156
- [*Note 1*: Futures, promises, and tasks defined in this clause
157
  reference such shared state. — *end note*]
158
 
159
  [*Note 2*: The result can be any kind of object including a function to
160
  compute that result, as used by `async` when `policy` is
161
  `launch::deferred`. — *end note*]
@@ -261,18 +269,18 @@ namespace std {
261
  // setting the result with deferred notification
262
  void set_value_at_thread_exit(see below);
263
  void set_exception_at_thread_exit(exception_ptr p);
264
  };
265
 
266
- template<class R>
267
- void swap(promise<R>& x, promise<R>& y) noexcept;
268
-
269
  template<class R, class Alloc>
270
  struct uses_allocator<promise<R>, Alloc>;
271
  }
272
  ```
273
 
 
 
 
274
  The implementation provides the template `promise` and two
275
  specializations, `promise<R&>` and `promise<{}void>`. These differ only
276
  in the argument type of the member functions `set_value` and
277
  `set_value_at_thread_exit`, as set out in their descriptions, below.
278
 
@@ -285,12 +293,12 @@ the promise object.
285
  template<class R, class Alloc>
286
  struct uses_allocator<promise<R>, Alloc>
287
  : true_type { };
288
  ```
289
 
290
- *Preconditions:* `Alloc` meets the *Cpp17Allocator* requirements
291
- ([[cpp17.allocator]]).
292
 
293
  ``` cpp
294
  promise();
295
  template<class Allocator>
296
  promise(allocator_arg_t, const Allocator& a);
@@ -335,19 +343,19 @@ to the call to `swap`. `other` has the shared state (if any) that
335
 
336
  ``` cpp
337
  future<R> get_future();
338
  ```
339
 
340
- *Returns:* A `future<R>` object with the same shared state as `*this`.
341
-
342
  *Synchronization:* Calls to this function do not introduce data
343
  races  [[intro.multithread]] with calls to `set_value`, `set_exception`,
344
  `set_value_at_thread_exit`, or `set_exception_at_thread_exit`.
345
 
346
  [*Note 1*: Such calls need not synchronize with each
347
  other. — *end note*]
348
 
 
 
349
  *Throws:* `future_error` if `*this` has no shared state or if
350
  `get_future` has already been called on a `promise` with the same shared
351
  state as `*this`.
352
 
353
  *Error conditions:*
@@ -471,13 +479,13 @@ move-assignment operator, `share`, or `valid` on a `future` object for
471
  which `valid() == false` is undefined.
472
 
473
  [*Note 2*: It is valid to move from a future object for which
474
  `valid() == false`. — *end note*]
475
 
476
- [*Note 3*: Implementations should detect this case and throw an object
477
- of type `future_error` with an error condition of
478
- `future_errc::no_state`. — *end note*]
479
 
480
  ``` cpp
481
  namespace std {
482
  template<class R>
483
  class future {
@@ -503,10 +511,13 @@ namespace std {
503
  future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
504
  };
505
  }
506
  ```
507
 
 
 
 
508
  The implementation provides the template `future` and two
509
  specializations, `future<R&>` and `future<{}void>`. These differ only in
510
  the return type and return value of the member function `get`, as set
511
  out in its description, below.
512
 
@@ -542,29 +553,30 @@ state that was originally referred to by `rhs` (if any).
542
 
543
  ``` cpp
544
  future& operator=(future&& rhs) noexcept;
545
  ```
546
 
547
- *Effects:*
 
548
 
549
  - Releases any shared state [[futures.state]].
550
  - move assigns the contents of `rhs` to `*this`.
551
 
552
  *Ensures:*
553
 
554
  - `valid()` returns the same value as `rhs.valid()` prior to the
555
  assignment.
556
- - `rhs.valid() == false`.
557
 
558
  ``` cpp
559
  shared_future<R> share() noexcept;
560
  ```
561
 
 
 
562
  *Returns:* `shared_future<R>(std::move(*this))`.
563
 
564
- *Ensures:* `valid() == false`.
565
-
566
  ``` cpp
567
  R future::get();
568
  R& future<R&>::get();
569
  void future<void>::get();
570
  ```
@@ -577,10 +589,12 @@ member function `get`. — *end note*]
577
 
578
  - `wait()`s until the shared state is ready, then retrieves the value
579
  stored in the shared state;
580
  - releases any shared state [[futures.state]].
581
 
 
 
582
  *Returns:*
583
 
584
  - `future::get()` returns the value `v` stored in the object’s shared
585
  state as `std::move(v)`.
586
  - `future<R&>::get()` returns the reference stored as value in the
@@ -588,12 +602,10 @@ member function `get`. — *end note*]
588
  - `future<void>::get()` returns nothing.
589
 
590
  *Throws:* The stored exception, if an exception was stored in the shared
591
  state.
592
 
593
- *Ensures:* `valid() == false`.
594
-
595
  ``` cpp
596
  bool valid() const noexcept;
597
  ```
598
 
599
  *Returns:* `true` only if `*this` refers to a shared state.
@@ -666,13 +678,13 @@ move-assignment operator, the copy-assignment operator, or `valid()` on
666
  a `shared_future` object for which `valid() == false` is undefined.
667
 
668
  [*Note 2*: It is valid to copy or move from a `shared_future` object
669
  for which `valid()` is `false`. — *end note*]
670
 
671
- [*Note 3*: Implementations should detect this case and throw an object
672
- of type `future_error` with an error condition of
673
- `future_errc::no_state`. — *end note*]
674
 
675
  ``` cpp
676
  namespace std {
677
  template<class R>
678
  class shared_future {
@@ -698,10 +710,13 @@ namespace std {
698
  future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
699
  };
700
  }
701
  ```
702
 
 
 
 
703
  The implementation provides the template `shared_future` and two
704
  specializations, `shared_future<R&>` and `shared_future<void>`. These
705
  differ only in the return type and return value of the member function
706
  `get`, as set out in its description, below.
707
 
@@ -746,29 +761,31 @@ shared state that was originally referred to by `rhs` (if any).
746
 
747
  ``` cpp
748
  shared_future& operator=(shared_future&& rhs) noexcept;
749
  ```
750
 
751
- *Effects:*
 
752
 
753
  - Releases any shared state [[futures.state]];
754
  - move assigns the contents of `rhs` to `*this`.
755
 
756
  *Ensures:*
757
 
758
  - `valid()` returns the same value as `rhs.valid()` returned prior to
759
  the assignment.
760
- - `rhs.valid() == false`.
761
 
762
  ``` cpp
763
  shared_future& operator=(const shared_future& rhs) noexcept;
764
  ```
765
 
766
- *Effects:*
 
767
 
768
  - Releases any shared state [[futures.state]];
769
- - assigns the contents of `rhs` to `*this`. \[*Note 4*: As a result,
770
  `*this` refers to the same shared state as `rhs` (if
771
  any). — *end note*]
772
 
773
  *Ensures:* `valid() == rhs.valid()`.
774
 
@@ -781,20 +798,20 @@ void shared_future<void>::get() const;
781
  [*Note 1*: As described above, the template and its two required
782
  specializations differ only in the return type and return value of the
783
  member function `get`. — *end note*]
784
 
785
  [*Note 2*: Access to a value object stored in the shared state is
786
- unsynchronized, so programmers should apply only those operations on `R`
787
- that do not introduce a data race [[intro.multithread]]. — *end note*]
788
 
789
  *Effects:* `wait()`s until the shared state is ready, then retrieves the
790
  value stored in the shared state.
791
 
792
  *Returns:*
793
 
794
  - `shared_future::get()` returns a const reference to the value stored
795
- in the object’s shared state. \[*Note 5*: Access through that
796
  reference after the shared state has been destroyed produces undefined
797
  behavior; this can be avoided by not storing the reference in any
798
  storage with a greater lifetime than the `shared_future` object that
799
  returned the reference. — *end note*]
800
  - `shared_future<R&>::get()` returns the reference stored as value in
@@ -874,82 +891,64 @@ template<class F, class... Args>
874
  ```
875
 
876
  *Mandates:* The following are all `true`:
877
 
878
  - `is_constructible_v<decay_t<F>, F>`,
879
- - `(is_constructible_v<decay_t<Args>, Args> &&...)`,
880
- - `is_move_constructible_v<decay_t<F>>`,
881
- - `(is_move_constructible_v<decay_t<Args>> &&...)`, and
882
  - `is_invocable_v<decay_t<F>, decay_t<Args>...>`.
883
 
884
- *Preconditions:* `decay_t<F>` and each type in `decay_t<Args>` meet the
885
- *Cpp17MoveConstructible* requirements.
886
-
887
  *Effects:* The first function behaves the same as a call to the second
888
  function with a `policy` argument of `launch::async | launch::deferred`
889
  and the same arguments for `F` and `Args`. The second function creates a
890
  shared state that is associated with the returned `future` object. The
891
  further behavior of the second function depends on the `policy` argument
892
  as follows (if more than one of these conditions applies, the
893
  implementation may choose any of the corresponding policies):
894
 
895
  - If `launch::async` is set in `policy`, calls
896
- `invoke(`*`decay-copy`*`(std::forward<F>(f)),`
897
- *decay-copy*(std::forward\<Args\>(args))...) ([[func.require]],
898
- [[thread.thread.constr]]) as if in a new thread of execution
899
- represented by a `thread` object with the calls to *`decay-copy`*
900
- being evaluated in the thread that called `async`. Any return value is
901
- stored as the result in the shared state. Any exception propagated
902
- from the execution of
903
- `invoke(`*`decay-copy`*`(std::forward<F>(f)), `*`decay-copy`*`(std::forward<Args>(args))...)`
904
  is stored as the exceptional result in the shared state. The `thread`
905
  object is stored in the shared state and affects the behavior of any
906
  asynchronous return objects that reference that state.
907
  - If `launch::deferred` is set in `policy`, stores
908
- *decay-copy*(std::forward\<F\>(f)) and
909
- *decay-copy*(std::forward\<Args\>(args))... in the shared state. These
910
- copies of `f` and `args` constitute a *deferred function*. Invocation
911
- of the deferred function evaluates
912
  `invoke(std::move(g), std::move(xyz))` where `g` is the stored value
913
- of *decay-copy*(std::forward\<F\>(f)) and `xyz` is the stored copy of
914
- *decay-copy*(std::forward\<Args\>(args)).... Any return value is
915
- stored as the result in the shared state. Any exception propagated
916
- from the execution of the deferred function is stored as the
917
- exceptional result in the shared state. The shared state is not made
918
- ready until the function has completed. The first call to a non-timed
919
- waiting function [[futures.state]] on an asynchronous return object
920
- referring to this shared state invokes the deferred function in the
921
- thread that called the waiting function. Once evaluation of
922
  `invoke(std::move(g), std::move(xyz))` begins, the function is no
923
- longer considered deferred. \[*Note 1*: If this policy is specified
924
- together with other policies, such as when using a `policy` value of
925
- `launch::async | launch::deferred`, implementations should defer
926
- invocation or the selection of the policy when no more concurrency can
927
- be effectively exploited. — *end note*]
928
  - If no value is set in the launch policy, or a value is set that is
929
  neither specified in this document nor by the implementation, the
930
  behavior is undefined.
931
 
932
- *Returns:* An object of type
933
- `future<invoke_result_t<decay_t<F>, decay_t<Args>...>``>` that refers to
934
- the shared state created by this call to `async`.
935
 
936
- [*Note 1*: If a future obtained from `async` is moved outside the local
937
- scope, other code that uses the future should be aware that the future’s
938
- destructor can block for the shared state to become
939
- ready. — *end note*]
940
-
941
- *Synchronization:* Regardless of the provided `policy` argument,
942
-
943
- - the invocation of `async` synchronizes with [[intro.multithread]] the
944
- invocation of `f`. \[*Note 2*: This statement applies even when the
945
- corresponding `future` object is moved to another
946
- thread. — *end note*] ; and
947
- - the completion of the function `f` is sequenced
948
- before [[intro.multithread]] the shared state is made ready.
949
- \[*Note 3*: `f` might not be called at all, so its completion might
950
- never happen. — *end note*]
951
 
952
  If the implementation chooses the `launch::async` policy,
953
 
954
  - a call to a waiting function on an asynchronous return object that
955
  shares the shared state created by this `async` call shall block until
@@ -959,27 +958,37 @@ If the implementation chooses the `launch::async` policy,
959
  with [[intro.multithread]] the return from the first function that
960
  successfully detects the ready status of the shared state or with the
961
  return from the last function that releases the shared state,
962
  whichever happens first.
963
 
 
 
 
 
 
 
 
 
964
  *Throws:* `system_error` if `policy == launch::async` and the
965
  implementation is unable to start a new thread, or `std::bad_alloc` if
966
- memory for the internal data structures could not be allocated.
967
 
968
  *Error conditions:*
969
 
970
  - `resource_unavailable_try_again` — if `policy == launch::async` and
971
  the system is unable to start a new thread.
972
 
973
- [*Note 4*: Line \#1 might not result in concurrency because the `async`
974
- call uses the default policy, which may use `launch::deferred`, in which
975
- case the lambda might not be invoked until the `get()` call; in that
976
- case, `work1` and `work2` are called on the same thread and there is no
977
- concurrency. — *end note*]
978
 
979
  ### Class template `packaged_task` <a id="futures.task">[[futures.task]]</a>
980
 
 
 
981
  The class template `packaged_task` defines a type for wrapping a
982
  function or callable object so that the return value of the function or
983
  callable object is stored in a future when it is invoked.
984
 
985
  When the `packaged_task` object is invoked, its stored task is invoked
@@ -1020,11 +1029,13 @@ namespace std {
1020
 
1021
  void reset();
1022
  };
1023
 
1024
  template<class R, class... ArgTypes>
1025
- void swap(packaged_task<R(ArgTypes...)>& x, packaged_task<R(ArgTypes...)>& y) noexcept;
 
 
1026
  }
1027
  ```
1028
 
1029
  #### Member functions <a id="futures.task.members">[[futures.task.members]]</a>
1030
 
@@ -1034,11 +1045,11 @@ packaged_task() noexcept;
1034
 
1035
  *Effects:* The object has no shared state and no stored task.
1036
 
1037
  ``` cpp
1038
  template<class F>
1039
- packaged_task(F&& f);
1040
  ```
1041
 
1042
  *Constraints:* `remove_cvref_t<F>` is not the same type as
1043
  `packaged_task<R(ArgTypes...)>`.
1044
 
@@ -1049,13 +1060,29 @@ template<class F>
1049
 
1050
  *Effects:* Constructs a new `packaged_task` object with a shared state
1051
  and initializes the object’s stored task with `std::forward<F>(f)`.
1052
 
1053
  *Throws:* Any exceptions thrown by the copy or move constructor of `f`,
1054
- or `bad_alloc` if memory for the internal data structures could not be
1055
  allocated.
1056
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1057
  ``` cpp
1058
  packaged_task(packaged_task&& rhs) noexcept;
1059
  ```
1060
 
1061
  *Effects:* Transfers ownership of `rhs`’s shared state to `*this`,
@@ -1098,20 +1125,20 @@ bool valid() const noexcept;
1098
 
1099
  ``` cpp
1100
  future<R> get_future();
1101
  ```
1102
 
1103
- *Returns:* A `future` object that shares the same shared state as
1104
- `*this`.
1105
-
1106
  *Synchronization:* Calls to this function do not introduce data
1107
  races  [[intro.multithread]] with calls to `operator()` or
1108
  `make_ready_at_thread_exit`.
1109
 
1110
  [*Note 1*: Such calls need not synchronize with each
1111
  other. — *end note*]
1112
 
 
 
 
1113
  *Throws:* A `future_error` object if an error occurs.
1114
 
1115
  *Error conditions:*
1116
 
1117
  - `future_already_retrieved` if `get_future` has already been called on
@@ -1171,12 +1198,12 @@ task stored in `*this`.
1171
  [*Note 2*: This constructs a new shared state for `*this`. The old
1172
  state is abandoned [[futures.state]]. — *end note*]
1173
 
1174
  *Throws:*
1175
 
1176
- - `bad_alloc` if memory for the new shared state could not be allocated.
1177
- - any exception thrown by the move constructor of the task stored in the
1178
  shared state.
1179
  - `future_error` with an error condition of `no_state` if `*this` has no
1180
  shared state.
1181
 
1182
  #### Globals <a id="futures.task.nonmembers">[[futures.task.nonmembers]]</a>
@@ -1188,139 +1215,209 @@ template<class R, class... ArgTypes>
1188
 
1189
  *Effects:* As if by `x.swap(y)`.
1190
 
1191
  <!-- Link reference definitions -->
1192
  [alg.sorting]: algorithms.md#alg.sorting
1193
- [atomics]: atomics.md#atomics
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1194
  [barrier.syn]: #barrier.syn
 
 
1195
  [basic.life]: basic.md#basic.life
1196
  [basic.stc.thread]: basic.md#basic.stc.thread
1197
  [bitmask.types]: library.md#bitmask.types
 
1198
  [class.prop]: class.md#class.prop
 
 
1199
  [condition.variable.syn]: #condition.variable.syn
1200
- [cpp17.allocator]: #cpp17.allocator
1201
  [cpp17.defaultconstructible]: #cpp17.defaultconstructible
1202
  [cpp17.destructible]: #cpp17.destructible
1203
  [cpp17.moveassignable]: #cpp17.moveassignable
1204
  [cpp17.moveconstructible]: #cpp17.moveconstructible
1205
  [defns.block]: intro.md#defns.block
1206
  [except.terminate]: except.md#except.terminate
 
 
 
1207
  [func.require]: utilities.md#func.require
 
1208
  [future.syn]: #future.syn
1209
  [futures]: #futures
1210
  [futures.async]: #futures.async
1211
  [futures.errors]: #futures.errors
1212
  [futures.future.error]: #futures.future.error
1213
  [futures.overview]: #futures.overview
1214
  [futures.promise]: #futures.promise
1215
  [futures.shared.future]: #futures.shared.future
1216
  [futures.state]: #futures.state
1217
  [futures.task]: #futures.task
 
1218
  [futures.task.members]: #futures.task.members
1219
  [futures.task.nonmembers]: #futures.task.nonmembers
1220
  [futures.unique.future]: #futures.unique.future
1221
  [intro.multithread]: basic.md#intro.multithread
 
1222
  [intro.races]: basic.md#intro.races
1223
  [latch.syn]: #latch.syn
 
1224
  [mutex.syn]: #mutex.syn
1225
  [res.on.data.races]: library.md#res.on.data.races
1226
  [res.on.exception.handling]: library.md#res.on.exception.handling
1227
  [semaphore.syn]: #semaphore.syn
1228
  [shared.mutex.syn]: #shared.mutex.syn
 
1229
  [stopcallback]: #stopcallback
1230
  [stopcallback.cons]: #stopcallback.cons
 
1231
  [stopsource]: #stopsource
1232
  [stopsource.cons]: #stopsource.cons
 
1233
  [stopsource.mem]: #stopsource.mem
1234
  [stopsource.nonmembers]: #stopsource.nonmembers
1235
  [stoptoken]: #stoptoken
1236
  [stoptoken.cons]: #stoptoken.cons
 
1237
  [stoptoken.mem]: #stoptoken.mem
1238
  [stoptoken.nonmembers]: #stoptoken.nonmembers
1239
  [syserr]: diagnostics.md#syserr
1240
  [syserr.syserr]: diagnostics.md#syserr.syserr
 
 
1241
  [thread]: #thread
1242
  [thread.barrier]: #thread.barrier
1243
  [thread.barrier.class]: #thread.barrier.class
 
1244
  [thread.condition]: #thread.condition
1245
  [thread.condition.condvar]: #thread.condition.condvar
1246
  [thread.condition.condvarany]: #thread.condition.condvarany
 
 
1247
  [thread.condition.nonmember]: #thread.condition.nonmember
1248
  [thread.condvarany.intwait]: #thread.condvarany.intwait
1249
  [thread.condvarany.wait]: #thread.condvarany.wait
1250
  [thread.coord]: #thread.coord
 
1251
  [thread.general]: #thread.general
1252
  [thread.jthread.class]: #thread.jthread.class
 
1253
  [thread.jthread.cons]: #thread.jthread.cons
1254
  [thread.jthread.mem]: #thread.jthread.mem
1255
  [thread.jthread.special]: #thread.jthread.special
1256
  [thread.jthread.static]: #thread.jthread.static
1257
  [thread.jthread.stop]: #thread.jthread.stop
1258
  [thread.latch]: #thread.latch
1259
  [thread.latch.class]: #thread.latch.class
 
1260
  [thread.lock]: #thread.lock
1261
  [thread.lock.algorithm]: #thread.lock.algorithm
 
1262
  [thread.lock.guard]: #thread.lock.guard
1263
  [thread.lock.scoped]: #thread.lock.scoped
1264
  [thread.lock.shared]: #thread.lock.shared
1265
  [thread.lock.shared.cons]: #thread.lock.shared.cons
 
1266
  [thread.lock.shared.locking]: #thread.lock.shared.locking
1267
  [thread.lock.shared.mod]: #thread.lock.shared.mod
1268
  [thread.lock.shared.obs]: #thread.lock.shared.obs
1269
  [thread.lock.unique]: #thread.lock.unique
1270
  [thread.lock.unique.cons]: #thread.lock.unique.cons
 
1271
  [thread.lock.unique.locking]: #thread.lock.unique.locking
1272
  [thread.lock.unique.mod]: #thread.lock.unique.mod
1273
  [thread.lock.unique.obs]: #thread.lock.unique.obs
1274
  [thread.mutex]: #thread.mutex
1275
  [thread.mutex.class]: #thread.mutex.class
 
1276
  [thread.mutex.recursive]: #thread.mutex.recursive
1277
  [thread.mutex.requirements]: #thread.mutex.requirements
1278
  [thread.mutex.requirements.general]: #thread.mutex.requirements.general
1279
  [thread.mutex.requirements.mutex]: #thread.mutex.requirements.mutex
 
1280
  [thread.once]: #thread.once
1281
  [thread.once.callonce]: #thread.once.callonce
1282
  [thread.once.onceflag]: #thread.once.onceflag
1283
  [thread.req]: #thread.req
1284
  [thread.req.exception]: #thread.req.exception
1285
  [thread.req.lockable]: #thread.req.lockable
1286
  [thread.req.lockable.basic]: #thread.req.lockable.basic
1287
  [thread.req.lockable.general]: #thread.req.lockable.general
1288
  [thread.req.lockable.req]: #thread.req.lockable.req
 
 
1289
  [thread.req.lockable.timed]: #thread.req.lockable.timed
1290
  [thread.req.native]: #thread.req.native
1291
  [thread.req.paramname]: #thread.req.paramname
1292
  [thread.req.timing]: #thread.req.timing
1293
  [thread.sema]: #thread.sema
1294
  [thread.sema.cnt]: #thread.sema.cnt
 
1295
  [thread.sharedmutex.class]: #thread.sharedmutex.class
1296
  [thread.sharedmutex.requirements]: #thread.sharedmutex.requirements
 
1297
  [thread.sharedtimedmutex.class]: #thread.sharedtimedmutex.class
1298
  [thread.sharedtimedmutex.requirements]: #thread.sharedtimedmutex.requirements
 
1299
  [thread.stoptoken]: #thread.stoptoken
1300
  [thread.stoptoken.intro]: #thread.stoptoken.intro
1301
  [thread.stoptoken.syn]: #thread.stoptoken.syn
1302
  [thread.summary]: #thread.summary
1303
  [thread.syn]: #thread.syn
1304
  [thread.thread.algorithm]: #thread.thread.algorithm
1305
  [thread.thread.assign]: #thread.thread.assign
1306
  [thread.thread.class]: #thread.thread.class
 
1307
  [thread.thread.constr]: #thread.thread.constr
1308
  [thread.thread.destr]: #thread.thread.destr
1309
  [thread.thread.id]: #thread.thread.id
1310
  [thread.thread.member]: #thread.thread.member
1311
  [thread.thread.static]: #thread.thread.static
1312
  [thread.thread.this]: #thread.thread.this
1313
  [thread.threads]: #thread.threads
 
1314
  [thread.timedmutex.class]: #thread.timedmutex.class
1315
  [thread.timedmutex.recursive]: #thread.timedmutex.recursive
1316
  [thread.timedmutex.requirements]: #thread.timedmutex.requirements
 
1317
  [time]: time.md#time
1318
  [time.clock]: time.md#time.clock
1319
  [time.clock.req]: time.md#time.clock.req
1320
  [time.duration]: time.md#time.duration
1321
  [time.point]: time.md#time.point
1322
  [unord.hash]: utilities.md#unord.hash
 
 
 
 
 
1323
 
1324
- [^1]: All implementations for which standard time units are meaningful
1325
- must necessarily have a steady clock within their hardware
1326
- implementation.
 
 
 
13
  ### Header `<future>` synopsis <a id="future.syn">[[future.syn]]</a>
14
 
15
  ``` cpp
16
  namespace std {
17
  enum class future_errc {
18
+ broken_promise = implementation-defined // value of future_errc::broken_promise,
19
+ future_already_retrieved = implementation-defined // value of future_errc::future_already_retrieved,
20
+ promise_already_satisfied = implementation-defined // value of future_errc::promise_already_satisfied,
21
+ no_state = implementation-defined // value of future_errc::no_state
22
  };
23
 
24
  enum class launch : unspecified{} {
25
  async = unspecified{},
26
  deferred = unspecified{},
27
+ implementation-defined // last enumerator of launch
28
  };
29
 
30
  enum class future_status {
31
  ready,
32
  timeout,
33
  deferred
34
  };
35
 
36
+ // [futures.errors], error handling
37
  template<> struct is_error_code_enum<future_errc> : public true_type { };
38
  error_code make_error_code(future_errc e) noexcept;
39
  error_condition make_error_condition(future_errc e) noexcept;
40
 
41
  const error_category& future_category() noexcept;
42
 
43
+ // [futures.future.error], class future_error
44
  class future_error;
45
 
46
+ // [futures.promise], class template promise
47
  template<class R> class promise;
48
  template<class R> class promise<R&>;
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
 
62
+ // [futures.shared.future], class template shared_future
63
  template<class R> class shared_future;
64
  template<class R> class shared_future<R&>;
65
  template<> class shared_future<void>;
66
 
67
+ // [futures.task], class template packaged_task
68
  template<class> class packaged_task; // not defined
69
  template<class R, class... ArgTypes>
70
  class packaged_task<R(ArgTypes...)>;
71
 
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
  [[nodiscard]] future<invoke_result_t<decay_t<F>, decay_t<Args>...>>
78
  async(F&& f, Args&&... args);
79
  template<class F, class... Args>
80
  [[nodiscard]] future<invoke_result_t<decay_t<F>, decay_t<Args>...>>
 
100
  ```
101
 
102
  *Returns:* A reference to an object of a type derived from class
103
  `error_category`.
104
 
105
+ The object’s `default_error_condition` and `equivalent` virtual
106
+ functions shall behave as specified for the class `error_category`. The
107
+ object’s `name` virtual function returns a pointer to the string
108
+ `"future"`.
109
 
110
  ``` cpp
111
  error_code make_error_code(future_errc e) noexcept;
112
  ```
113
 
 
159
  Many of the classes introduced in subclause  [[futures]] use some state
160
  to communicate results. This *shared state* consists of some state
161
  information and some (possibly not yet evaluated) *result*, which can be
162
  a (possibly void) value or an exception.
163
 
164
+ [*Note 1*: Futures, promises, and tasks defined in this Clause
165
  reference such shared state. — *end note*]
166
 
167
  [*Note 2*: The result can be any kind of object including a function to
168
  compute that result, as used by `async` when `policy` is
169
  `launch::deferred`. — *end note*]
 
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.
281
+
282
  The implementation provides the template `promise` and two
283
  specializations, `promise<R&>` and `promise<{}void>`. These differ only
284
  in the argument type of the member functions `set_value` and
285
  `set_value_at_thread_exit`, as set out in their descriptions, below.
286
 
 
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);
 
343
 
344
  ``` cpp
345
  future<R> get_future();
346
  ```
347
 
 
 
348
  *Synchronization:* Calls to this function do not introduce data
349
  races  [[intro.multithread]] with calls to `set_value`, `set_exception`,
350
  `set_value_at_thread_exit`, or `set_exception_at_thread_exit`.
351
 
352
  [*Note 1*: Such calls need not synchronize with each
353
  other. — *end note*]
354
 
355
+ *Returns:* A `future<R>` object with the same shared state as `*this`.
356
+
357
  *Throws:* `future_error` if `*this` has no shared state or if
358
  `get_future` has already been called on a `promise` with the same shared
359
  state as `*this`.
360
 
361
  *Error conditions:*
 
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
 
484
+ *Recommended practice:* Implementations should detect this case and
485
+ throw an object of type `future_error` with an error condition of
486
+ `future_errc::no_state`.
487
 
488
  ``` cpp
489
  namespace std {
490
  template<class R>
491
  class future {
 
511
  future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
512
  };
513
  }
514
  ```
515
 
516
+ For the primary template, `R` shall be an object type that meets the
517
+ *Cpp17Destructible* requirements.
518
+
519
  The implementation provides the template `future` and two
520
  specializations, `future<R&>` and `future<{}void>`. These differ only in
521
  the return type and return value of the member function `get`, as set
522
  out in its description, below.
523
 
 
553
 
554
  ``` cpp
555
  future& operator=(future&& rhs) noexcept;
556
  ```
557
 
558
+ *Effects:* If `addressof(rhs) == this` is `true`, there are no effects.
559
+ Otherwise:
560
 
561
  - Releases any shared state [[futures.state]].
562
  - move assigns the contents of `rhs` to `*this`.
563
 
564
  *Ensures:*
565
 
566
  - `valid()` returns the same value as `rhs.valid()` prior to the
567
  assignment.
568
+ - If `addressof(rhs) == this` is `false`, `rhs.valid() == false`.
569
 
570
  ``` cpp
571
  shared_future<R> share() noexcept;
572
  ```
573
 
574
+ *Ensures:* `valid() == false`.
575
+
576
  *Returns:* `shared_future<R>(std::move(*this))`.
577
 
 
 
578
  ``` cpp
579
  R future::get();
580
  R& future<R&>::get();
581
  void future<void>::get();
582
  ```
 
589
 
590
  - `wait()`s until the shared state is ready, then retrieves the value
591
  stored in the shared state;
592
  - releases any shared state [[futures.state]].
593
 
594
+ *Ensures:* `valid() == false`.
595
+
596
  *Returns:*
597
 
598
  - `future::get()` returns the value `v` stored in the object’s shared
599
  state as `std::move(v)`.
600
  - `future<R&>::get()` returns the reference stored as value in the
 
602
  - `future<void>::get()` returns nothing.
603
 
604
  *Throws:* The stored exception, if an exception was stored in the shared
605
  state.
606
 
 
 
607
  ``` cpp
608
  bool valid() const noexcept;
609
  ```
610
 
611
  *Returns:* `true` only if `*this` refers to a shared state.
 
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
 
683
+ *Recommended practice:* Implementations should detect this case and
684
+ throw an object of type `future_error` with an error condition of
685
+ `future_errc::no_state`.
686
 
687
  ``` cpp
688
  namespace std {
689
  template<class R>
690
  class shared_future {
 
710
  future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
711
  };
712
  }
713
  ```
714
 
715
+ For the primary template, `R` shall be an object type that meets the
716
+ *Cpp17Destructible* requirements.
717
+
718
  The implementation provides the template `shared_future` and two
719
  specializations, `shared_future<R&>` and `shared_future<void>`. These
720
  differ only in the return type and return value of the member function
721
  `get`, as set out in its description, below.
722
 
 
761
 
762
  ``` cpp
763
  shared_future& operator=(shared_future&& rhs) noexcept;
764
  ```
765
 
766
+ *Effects:* If `addressof(rhs) == this` is `true`, there are no effects.
767
+ Otherwise:
768
 
769
  - Releases any shared state [[futures.state]];
770
  - move assigns the contents of `rhs` to `*this`.
771
 
772
  *Ensures:*
773
 
774
  - `valid()` returns the same value as `rhs.valid()` returned prior to
775
  the assignment.
776
+ - If `addressof(rhs) == this` is `false`, `rhs.valid() == false`.
777
 
778
  ``` cpp
779
  shared_future& operator=(const shared_future& rhs) noexcept;
780
  ```
781
 
782
+ *Effects:* If `addressof(rhs) == this` is `true`, there are no effects.
783
+ Otherwise:
784
 
785
  - Releases any shared state [[futures.state]];
786
+ - assigns the contents of `rhs` to `*this`. \[*Note 3*: As a result,
787
  `*this` refers to the same shared state as `rhs` (if
788
  any). — *end note*]
789
 
790
  *Ensures:* `valid() == rhs.valid()`.
791
 
 
798
  [*Note 1*: As described above, the template and its two required
799
  specializations differ only in the return type and return value of the
800
  member function `get`. — *end note*]
801
 
802
  [*Note 2*: Access to a value object stored in the shared state is
803
+ unsynchronized, so operations on `R` might introduce a data
804
+ race [[intro.multithread]]. — *end note*]
805
 
806
  *Effects:* `wait()`s until the shared state is ready, then retrieves the
807
  value stored in the shared state.
808
 
809
  *Returns:*
810
 
811
  - `shared_future::get()` returns a const reference to the value stored
812
+ in the object’s shared state. \[*Note 4*: Access through that
813
  reference after the shared state has been destroyed produces undefined
814
  behavior; this can be avoided by not storing the reference in any
815
  storage with a greater lifetime than the `shared_future` object that
816
  returned the reference. — *end note*]
817
  - `shared_future<R&>::get()` returns the reference stored as value in
 
891
  ```
892
 
893
  *Mandates:* The following are all `true`:
894
 
895
  - `is_constructible_v<decay_t<F>, F>`,
896
+ - `(is_constructible_v<decay_t<Args>, Args> && ...)`, and
 
 
897
  - `is_invocable_v<decay_t<F>, decay_t<Args>...>`.
898
 
 
 
 
899
  *Effects:* The first function behaves the same as a call to the second
900
  function with a `policy` argument of `launch::async | launch::deferred`
901
  and the same arguments for `F` and `Args`. The second function creates a
902
  shared state that is associated with the returned `future` object. The
903
  further behavior of the second function depends on the `policy` argument
904
  as follows (if more than one of these conditions applies, the
905
  implementation may choose any of the corresponding policies):
906
 
907
  - If `launch::async` is set in `policy`, calls
908
+ `invoke(auto(std::forward<F>(f)), auto(std::forward<Args>(args))...)`
909
+ [[func.invoke]], [[thread.thread.constr]] as if in a new thread of
910
+ execution represented by a `thread` object with the values produced by
911
+ `auto` being materialized [[conv.rval]] in the thread that called
912
+ `async`. Any return value is stored as the result in the shared state.
913
+ Any exception propagated from the execution of
914
+ `invoke(auto(std::forward<F>(f)), auto(std::forward<Args>(args))...)`
 
915
  is stored as the exceptional result in the shared state. The `thread`
916
  object is stored in the shared state and affects the behavior of any
917
  asynchronous return objects that reference that state.
918
  - If `launch::deferred` is set in `policy`, stores
919
+ `auto(std::forward<F>(f))` and `auto(std::forward<Args>(args))...` in
920
+ the shared state. These copies of `f` and `args` constitute a
921
+ *deferred function*. Invocation of the deferred function evaluates
 
922
  `invoke(std::move(g), std::move(xyz))` where `g` is the stored value
923
+ of `auto(std::forward<F>(f))` and `xyz` is the stored copy of
924
+ `auto(std::forward<Args>(args))...`. Any return value is stored as the
925
+ result in the shared state. Any exception propagated from the
926
+ execution of the deferred function is stored as the exceptional result
927
+ in the shared state. The shared state is not made ready until the
928
+ function has completed. The first call to a non-timed waiting
929
+ function [[futures.state]] on an asynchronous return object referring
930
+ to this shared state invokes the deferred function in the thread that
931
+ called the waiting function. Once evaluation of
932
  `invoke(std::move(g), std::move(xyz))` begins, the function is no
933
+ longer considered deferred. *Recommended practice:* If this policy is
934
+ specified together with other policies, such as when using a `policy`
935
+ value of `launch::async | launch::deferred`, implementations should
936
+ defer invocation or the selection of the policy when no more
937
+ concurrency can be effectively exploited.
938
  - If no value is set in the launch policy, or a value is set that is
939
  neither specified in this document nor by the implementation, the
940
  behavior is undefined.
941
 
942
+ *Synchronization:* The invocation of `async` synchronizes with the
943
+ invocation of `f`. The completion of the function `f` is sequenced
944
+ before the shared state is made ready.
945
 
946
+ [*Note 1*: These apply regardless of the provided `policy` argument,
947
+ and even if the corresponding `future` object is moved to another
948
+ thread. However, it is possible for `f` not to be called at all, in
949
+ which case its completion never happens. — *end note*]
 
 
 
 
 
 
 
 
 
 
 
950
 
951
  If the implementation chooses the `launch::async` policy,
952
 
953
  - a call to a waiting function on an asynchronous return object that
954
  shares the shared state created by this `async` call shall block until
 
958
  with [[intro.multithread]] the return from the first function that
959
  successfully detects the ready status of the shared state or with the
960
  return from the last function that releases the shared state,
961
  whichever happens first.
962
 
963
+ *Returns:* An object of type
964
+ `future<invoke_result_t<decay_t<F>, decay_t<Args>...>>` that refers to
965
+ the shared state created by this call to `async`.
966
+
967
+ [*Note 2*: If a future obtained from `async` is moved outside the local
968
+ scope, the future’s destructor can block for the shared state to become
969
+ ready. — *end note*]
970
+
971
  *Throws:* `system_error` if `policy == launch::async` and the
972
  implementation is unable to start a new thread, or `std::bad_alloc` if
973
+ memory for the internal data structures cannot be allocated.
974
 
975
  *Error conditions:*
976
 
977
  - `resource_unavailable_try_again` — if `policy == launch::async` and
978
  the system is unable to start a new thread.
979
 
980
+ [*Note 1*: Line \#1 might not result in concurrency because the `async`
981
+ call uses the default policy, which might use `launch::deferred`, in
982
+ which case the lambda might not be invoked until the `get()` call; in
983
+ that case, `work1` and `work2` are called on the same thread and there
984
+ is no concurrency. — *end note*]
985
 
986
  ### Class template `packaged_task` <a id="futures.task">[[futures.task]]</a>
987
 
988
+ #### General <a id="futures.task.general">[[futures.task.general]]</a>
989
+
990
  The class template `packaged_task` defines a type for wrapping a
991
  function or callable object so that the return value of the function or
992
  callable object is stored in a future when it is invoked.
993
 
994
  When the `packaged_task` object is invoked, its stored task is invoked
 
1029
 
1030
  void reset();
1031
  };
1032
 
1033
  template<class R, class... ArgTypes>
1034
+ packaged_task(R (*)(ArgTypes...)) -> packaged_task<R(ArgTypes...)>;
1035
+
1036
+ template<class F> packaged_task(F) -> packaged_task<see below>;
1037
  }
1038
  ```
1039
 
1040
  #### Member functions <a id="futures.task.members">[[futures.task.members]]</a>
1041
 
 
1045
 
1046
  *Effects:* The object has no shared state and no stored task.
1047
 
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
 
 
1060
 
1061
  *Effects:* Constructs a new `packaged_task` object with a shared state
1062
  and initializes the object’s stored task with `std::forward<F>(f)`.
1063
 
1064
  *Throws:* Any exceptions thrown by the copy or move constructor of `f`,
1065
+ or `bad_alloc` if memory for the internal data structures cannot be
1066
  allocated.
1067
 
1068
+ ``` cpp
1069
+ template<class F> packaged_task(F) -> packaged_task<see below>;
1070
+ ```
1071
+
1072
+ *Constraints:* `&F::operator()` is well-formed when treated as an
1073
+ unevaluated operand [[term.unevaluated.operand]] and either
1074
+
1075
+ - `F::operator()` is a non-static member function and
1076
+ `decltype(&F::operator())` is either of the form
1077
+ `R(G::*)(A...)` cv \\ₒₚₜ ` `noexceptₒₚₜ or of the form
1078
+ `R(*)(G, A...) `noexceptₒₚₜ for a type `G`, or
1079
+ - `F::operator()` is a static member function and
1080
+ `decltype(&F::operator())` is of the form `R(*)(A...) `noexceptₒₚₜ .
1081
+
1082
+ *Remarks:* The deduced type is `packaged_task<R(A...)>`.
1083
+
1084
  ``` cpp
1085
  packaged_task(packaged_task&& rhs) noexcept;
1086
  ```
1087
 
1088
  *Effects:* Transfers ownership of `rhs`’s shared state to `*this`,
 
1125
 
1126
  ``` cpp
1127
  future<R> get_future();
1128
  ```
1129
 
 
 
 
1130
  *Synchronization:* Calls to this function do not introduce data
1131
  races  [[intro.multithread]] with calls to `operator()` or
1132
  `make_ready_at_thread_exit`.
1133
 
1134
  [*Note 1*: Such calls need not synchronize with each
1135
  other. — *end note*]
1136
 
1137
+ *Returns:* A `future` object that shares the same shared state as
1138
+ `*this`.
1139
+
1140
  *Throws:* A `future_error` object if an error occurs.
1141
 
1142
  *Error conditions:*
1143
 
1144
  - `future_already_retrieved` if `get_future` has already been called on
 
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
+ - `bad_alloc` if memory for the new shared state cannot be allocated.
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>
 
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.