forked from cplusplus/fundamentals-ts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfutures.html
162 lines (119 loc) · 5.29 KB
/
futures.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<cxx-clause id="futures">
<h1>Futures</h1>
<cxx-section id="header.future.synop">
<h1>Header <experimental/future> synopsis</h1>
<cxx-ednote>
An additional editorial fix is applied in the declaration of <code>swap</code> for <code>packaged_task</code>
</cxx-ednote>
<pre><code>#include <future>
namespace std {
namespace experimental {
inline namespace fundamentals_v2 {
template <class R> class promise;
template <class R> class promise<R&>;
template <> class promise<void>;
template <class R>
void swap(promise<R>& x, promise<R>& y) noexcept;
template <class> class packaged_task; // undefined
template <class R, class... ArgTypes>
class packaged_task<R(ArgTypes...)>;
template <class R, class... ArgTypes>
void swap(packaged_task<R(ArgTypes...)>&, packaged_task<R(ArgTypes...)>&) noexcept;
} // namespace fundamentals_v2
} // namespace experimental
template <class R, class Alloc>
struct uses_allocator<experimental::promise<R>, Alloc>;
template <class R, class Alloc>
struct uses_allocator<experimental::packaged_task<R>, Alloc>;
} // namespace std</code></pre>
</cxx-section>
<cxx-section id="futures.promise">
<h1>Class template <code>promise</code></h1>
<p>
The specification of all declarations within this sub-clause <cxx-ref to="futures.promise"></cxx-ref>
and its sub-clauses are the same as the corresponding declarations,
as specified in <cxx-ref in="cxx" to="futures.promise"></cxx-ref>,
unless explicitly specified otherwise.
</p>
<pre><code>namespace std {
namespace experimental {
inline namespace fundamentals_v2 {
template <class R>
class promise {
public:
typedef erased_type allocator_type;
promise();
template <class Allocator>
promise(allocator_arg_t, const Allocator& a);
promise(promise&& rhs) noexcept;
promise(const promise& rhs) = delete;
~promise();
promise& operator=(promise&& rhs) noexcept;
promise& operator=(const promise& rhs) = delete;
void swap(promise& other) noexcept;
future<R> get_future();
void set_value(<em>see below</em>);
void set_exception(exception_ptr p);
void set_value_at_thread_exit(const R& r);
void set_value_at_thread_exit(<em>see below</em>);
void set_exception_at_thread_exit(exception_ptr p);
pmr::memory_resource* get_memory_resource();
};
template <class R>
void swap(promise<R>& x, promise<R>& y) noexcept;
} // namespace fundamentals_v2
} // namespace experimental
template <class R, class Alloc>
struct uses_allocator<experimental::promise<R>, Alloc>;
} // namespace std</code></pre>
<p>
When a <code>promise</code> constructor that takes a first argument of type <code>allocator_arg_t</code> is invoked,
the second argument is treated as a type-erased allocator (<cxx-ref to="memory.type.erased.allocator"></cxx-ref>).
</p>
</cxx-section>
<cxx-section id="futures.task">
<h1>Class template <code>packaged_task</code></h1>
<p>
The specification of all declarations within this sub-clause <cxx-ref to="futures.task"></cxx-ref>
and its sub-clauses are the same as the corresponding declarations,
as specified in <cxx-ref in="cxx" to="futures.task"></cxx-ref>,
unless explicitly specified otherwise.
</p>
<pre><code>namespace std {
namespace experimental {
inline namespace fundamentals_v2 {
template <class R, class... ArgTypes>
class packaged_task<R(ArgTypes...)> {
public:
typedef erased_type allocator_type;
packaged_task() noexcept;
template <class F>
explicit packaged_task(F&& f);
template <class F, class Allocator>
explicit packaged_task(allocator_arg_t, const Allocator& a, F&& f);
~packaged_task();
packaged_task(const packaged_task&) = delete;
packaged_task& operator=(const packaged_task&) = delete;
packaged_task(packaged_task&& rhs) noexcept;
packaged_task& operator=(packaged_task&& rhs) noexcept;
void swap(packaged_task& other) noexcept;
bool valid() const noexcept;
future<R> get_future();
void operator()(ArgTypes... );
void make_ready_at_thread_exit(ArgTypes...);
void reset();
pmr::memory_resource* get_memory_resource();
};
template <class R, class... ArgTypes>
void swap(packaged_task<R(ArgTypes...)>&, packaged_task<R(ArgTypes...)>&) noexcept;
} // namespace fundamentals_v2
} // namespace experimental
template <class R, class Alloc>
struct uses_allocator<experimental::packaged_task<R>, Alloc>;
} // namespace std</code></pre>
<p>
When a <code>packaged_task</code> constructor that takes a first argument of type <code>allocator_arg_t</code> is invoked,
the second argument is treated as a type-erased allocator (<cxx-ref to="memory.type.erased.allocator"></cxx-ref>).
</p>
</cxx-section>
</cxx-clause>