From Jason Turner

[futures.unique_future]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp47x1r63s/{from.md → to.md} +30 -22
tmp/tmp47x1r63s/{from.md → to.md} RENAMED
@@ -8,18 +8,23 @@ on asynchronous providers ([[futures.state]]) or by the move
8
  constructor and shares its shared state with the original asynchronous
9
  provider. The result (value or exception) of a `future` object can be
10
  set by calling a respective function on an object that shares the same
11
  shared state.
12
 
13
- Member functions of `future` do not synchronize with themselves or with
14
- member functions of `shared_future`.
15
 
16
  The effect of calling any member function other than the destructor, the
17
- move-assignment operator, or `valid` on a `future` object for which
18
- `valid() == false` is undefined. Implementations are encouraged to
19
- detect this case and throw an object of type `future_error` with an
20
- error condition of `future_errc::no_state`.
 
 
 
 
 
21
 
22
  ``` cpp
23
  namespace std {
24
  template <class R>
25
  class future {
@@ -28,11 +33,11 @@ namespace std {
28
  future(future&&) noexcept;
29
  future(const future& rhs) = delete;
30
  ~future();
31
  future& operator=(const future& rhs) = delete;
32
  future& operator=(future&&) noexcept;
33
- shared_future<R> share();
34
 
35
  // retrieving the value
36
  see below get();
37
 
38
  // functions to check state
@@ -54,20 +59,20 @@ out in its description, below.
54
 
55
  ``` cpp
56
  future() noexcept;
57
  ```
58
 
59
- *Effects:* constructs an *empty* `future` object that does not refer to
60
  a shared state.
61
 
62
- `valid() == false`.
63
 
64
  ``` cpp
65
  future(future&& rhs) noexcept;
66
  ```
67
 
68
- *Effects:* move constructs a `future` object that refers to the shared
69
  state that was originally referred to by `rhs` (if any).
70
 
71
  *Postconditions:*
72
 
73
  - `valid()` returns the same value as `rhs.valid()` prior to the
@@ -78,48 +83,51 @@ state that was originally referred to by `rhs` (if any).
78
  ~future();
79
  ```
80
 
81
  *Effects:*
82
 
83
- - releases any shared state ([[futures.state]]);
84
  - destroys `*this`.
85
 
86
  ``` cpp
87
  future& operator=(future&& rhs) noexcept;
88
  ```
89
 
90
  *Effects:*
91
 
92
- - releases any shared state ([[futures.state]]).
93
  - move assigns the contents of `rhs` to `*this`.
94
 
95
  *Postconditions:*
96
 
97
  - `valid()` returns the same value as `rhs.valid()` prior to the
98
  assignment.
99
  - `rhs.valid() == false`.
100
 
101
  ``` cpp
102
- shared_future<R> share();
103
  ```
104
 
105
  *Returns:* `shared_future<R>(std::move(*this))`.
106
 
107
- `valid() == false`.
108
 
109
  ``` cpp
110
  R future::get();
111
  R& future<R&>::get();
112
  void future<void>::get();
113
  ```
114
 
115
- *Note:* as described above, the template and its two required
116
  specializations differ only in the return type and return value of the
117
- member function `get`.
118
 
119
- *Effects:* `wait()`s until the shared state is ready, then retrieves the
120
- value stored in the shared state.
 
 
 
121
 
122
  *Returns:*
123
 
124
  - `future::get()` returns the value `v` stored in the object’s shared
125
  state as `std::move(v)`.
@@ -128,11 +136,11 @@ value stored in the shared state.
128
  - `future<void>::get()` returns nothing.
129
 
130
  *Throws:* the stored exception, if an exception was stored in the shared
131
  state.
132
 
133
- `valid() == false`.
134
 
135
  ``` cpp
136
  bool valid() const noexcept;
137
  ```
138
 
@@ -140,18 +148,18 @@ bool valid() const noexcept;
140
 
141
  ``` cpp
142
  void wait() const;
143
  ```
144
 
145
- *Effects:* blocks until the shared state is ready.
146
 
147
  ``` cpp
148
  template <class Rep, class Period>
149
  future_status wait_for(const chrono::duration<Rep, Period>& rel_time) const;
150
  ```
151
 
152
- *Effects:* none if the shared state contains a deferred
153
  function ([[futures.async]]), otherwise blocks until the shared state
154
  is ready or until the relative timeout ([[thread.req.timing]])
155
  specified by `rel_time` has expired.
156
 
157
  *Returns:*
@@ -168,11 +176,11 @@ specified by `rel_time` has expired.
168
  ``` cpp
169
  template <class Clock, class Duration>
170
  future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
171
  ```
172
 
173
- *Effects:* none if the shared state contains a deferred
174
  function ([[futures.async]]), otherwise blocks until the shared state
175
  is ready or until the absolute timeout ([[thread.req.timing]])
176
  specified by `abs_time` has expired.
177
 
178
  *Returns:*
 
8
  constructor and shares its shared state with the original asynchronous
9
  provider. The result (value or exception) of a `future` object can be
10
  set by calling a respective function on an object that shares the same
11
  shared state.
12
 
13
+ [*Note 1*: Member functions of `future` do not synchronize with
14
+ themselves or with member functions of `shared_future`. — *end note*]
15
 
16
  The effect of calling any member function other than the destructor, the
17
+ move-assignment operator, `share`, or `valid` on a `future` object for
18
+ which `valid() == false` is undefined.
19
+
20
+ [*Note 2*: It is valid to move from a future object for which
21
+ `valid() == false`. — *end note*]
22
+
23
+ [*Note 3*: Implementations are encouraged to detect this case and throw
24
+ an object of type `future_error` with an error condition of
25
+ `future_errc::no_state`. — *end note*]
26
 
27
  ``` cpp
28
  namespace std {
29
  template <class R>
30
  class future {
 
33
  future(future&&) noexcept;
34
  future(const future& rhs) = delete;
35
  ~future();
36
  future& operator=(const future& rhs) = delete;
37
  future& operator=(future&&) noexcept;
38
+ shared_future<R> share() noexcept;
39
 
40
  // retrieving the value
41
  see below get();
42
 
43
  // functions to check state
 
59
 
60
  ``` cpp
61
  future() noexcept;
62
  ```
63
 
64
+ *Effects:* Constructs an *empty* `future` object that does not refer to
65
  a shared state.
66
 
67
+ *Postconditions:* `valid() == false`.
68
 
69
  ``` cpp
70
  future(future&& rhs) noexcept;
71
  ```
72
 
73
+ *Effects:* Move constructs a `future` object that refers to the shared
74
  state that was originally referred to by `rhs` (if any).
75
 
76
  *Postconditions:*
77
 
78
  - `valid()` returns the same value as `rhs.valid()` prior to the
 
83
  ~future();
84
  ```
85
 
86
  *Effects:*
87
 
88
+ - Releases any shared state ([[futures.state]]);
89
  - destroys `*this`.
90
 
91
  ``` cpp
92
  future& operator=(future&& rhs) noexcept;
93
  ```
94
 
95
  *Effects:*
96
 
97
+ - Releases any shared state ([[futures.state]]).
98
  - move assigns the contents of `rhs` to `*this`.
99
 
100
  *Postconditions:*
101
 
102
  - `valid()` returns the same value as `rhs.valid()` prior to the
103
  assignment.
104
  - `rhs.valid() == false`.
105
 
106
  ``` cpp
107
+ shared_future<R> share() noexcept;
108
  ```
109
 
110
  *Returns:* `shared_future<R>(std::move(*this))`.
111
 
112
+ *Postconditions:* `valid() == false`.
113
 
114
  ``` cpp
115
  R future::get();
116
  R& future<R&>::get();
117
  void future<void>::get();
118
  ```
119
 
120
+ [*Note 1*: As described above, the template and its two required
121
  specializations differ only in the return type and return value of the
122
+ member function `get`. — *end note*]
123
 
124
+ *Effects:*
125
+
126
+ - `wait()`s until the shared state is ready, then retrieves the value
127
+ stored in the shared state;
128
+ - releases any shared state ([[futures.state]]).
129
 
130
  *Returns:*
131
 
132
  - `future::get()` returns the value `v` stored in the object’s shared
133
  state as `std::move(v)`.
 
136
  - `future<void>::get()` returns nothing.
137
 
138
  *Throws:* the stored exception, if an exception was stored in the shared
139
  state.
140
 
141
+ *Postconditions:* `valid() == false`.
142
 
143
  ``` cpp
144
  bool valid() const noexcept;
145
  ```
146
 
 
148
 
149
  ``` cpp
150
  void wait() const;
151
  ```
152
 
153
+ *Effects:* Blocks until the shared state is ready.
154
 
155
  ``` cpp
156
  template <class Rep, class Period>
157
  future_status wait_for(const chrono::duration<Rep, Period>& rel_time) const;
158
  ```
159
 
160
+ *Effects:* None if the shared state contains a deferred
161
  function ([[futures.async]]), otherwise blocks until the shared state
162
  is ready or until the relative timeout ([[thread.req.timing]])
163
  specified by `rel_time` has expired.
164
 
165
  *Returns:*
 
176
  ``` cpp
177
  template <class Clock, class Duration>
178
  future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
179
  ```
180
 
181
+ *Effects:* None if the shared state contains a deferred
182
  function ([[futures.async]]), otherwise blocks until the shared state
183
  is ready or until the absolute timeout ([[thread.req.timing]])
184
  specified by `abs_time` has expired.
185
 
186
  *Returns:*