977ed18d
Hu Chunming
提交三方库
|
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
|
[/
Copyright Oliver Kowalke 2013.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt
]
[#class_promise]
[section:promise Template `promise<>`]
A __promise__ provides a mechanism to store a value (or exception) that can
later be retrieved from the corresponding __future__ object. `promise<>` and
`future<>` communicate via their underlying [link shared_state shared state].
#include <boost/fiber/future/promise.hpp>
namespace boost {
namespace fibers {
template< typename R >
class promise {
public:
promise();
template< typename __Allocator__ >
promise( __allocator_arg_t__, Allocator);
promise( promise &&) noexcept;
promise & operator=( promise &&) noexcept;
promise( promise const&) = delete;
promise & operator=( promise const&) = delete;
~promise();
void swap( promise &) noexcept;
future< R > get_future();
void set_value( R const&); // member only of generic promise template
void set_value( R &&); // member only of generic promise template
void set_value( R &); // member only of promise< R & > template
void set_value(); // member only of promise< void > template
void set_exception( std::exception_ptr p);
};
template< typename R >
void swap( promise< R > &, promise< R > &) noexcept;
}
[heading Default constructor]
promise();
[variablelist
[[Effects:] [Creates a promise with an empty [link shared_state shared state].]]
[[Throws:] [Exceptions caused by memory allocation.]]
]
[heading Constructor]
template< typename __Allocator__ >
promise( __allocator_arg_t__, Allocator alloc);
[variablelist
[[Effects:] [Creates a promise with an empty [link shared_state shared state] by using `alloc`.]]
[[Throws:] [Exceptions caused by memory allocation.]]
[[See also:] [__allocator_arg_t__]]
]
[heading Move constructor]
promise( promise && other) noexcept;
[variablelist
[[Effects:] [Creates a promise by moving the [link shared_state shared state] from `other`.]]
[[Postcondition:] [`other` contains no valid shared state.]]
[[Throws:] [Nothing.]]
]
[heading Destructor]
~promise();
[variablelist
[[Effects:] [Destroys `*this` and abandons the [link shared_state shared
state] if shared state is ready; otherwise stores __future_error__ with error
condition __broken_promise__ as if by [member_link promise..set_exception]:
the shared state is set ready.]]
]
[operator_heading promise..operator_assign..operator=]
promise & operator=( promise && other) noexcept;
[variablelist
[[Effects:] [Transfers the ownership of [link shared_state shared state] to `*this`.]]
[[Postcondition:] [`other` contains no valid shared state.]]
[[Throws:] [Nothing.]]
]
[member_heading promise..swap]
void swap( promise & other) noexcept;
[variablelist
[[Effects:] [Swaps the [link shared_state shared state] between other and `*this`.]]
[[Throws:] [Nothing.]]
]
[member_heading promise..get_future]
future< R > get_future();
[variablelist
[[Returns:] [A __future__ with the same [link shared_state shared state].]]
[[Throws:] [__future_error__ with __already_retrieved__ or __no_state__.]]
]
[member_heading promise..set_value]
void set_value( R const& value); // member only of generic promise template
void set_value( R && value); // member only of generic promise template
void set_value( R & value); // member only of promise< R & > template
void set_value(); // member only of promise< void > template
[variablelist
[[Effects:] [Store the result in the [link shared_state shared state] and marks the state as ready.]]
[[Throws:] [__future_error__ with __already_satisfied__ or __no_state__.]]
]
[member_heading promise..set_exception]
void set_exception( std::exception_ptr);
[variablelist
[[Effects:] [Store an exception pointer in the [link shared_state shared state] and marks the state as ready.]]
[[Throws:] [__future_error__ with __already_satisfied__ or __no_state__.]]
]
[function_heading_for swap..promise]
template< typename R >
void swap( promise< R > & l, promise< R > & r) noexcept;
[variablelist
[[Effects:] [Same as `l.swap( r)`.]]
]
[endsect]
|