|
MSTL 1.4.0
A Modern C++ Library with extended functionality, web components, and utility libraries
|
Promise类模板 更多...
#include <promise.hpp>
Public 类型 | |
| using | state_type = _INNER __future_base::state_base |
| 状态类型 | |
| using | result_type = _INNER __future_base::basic_result<Res> |
| 结果类型 | |
| using | ptr_type = _INNER __future_base::Ptr<result_type> |
| 结果指针类型 | |
Public 成员函数 | |
| promise () | |
| 默认构造函数 | |
| promise (promise &&other) noexcept | |
| 移动构造函数 | |
| promise & | operator= (promise &&other) noexcept |
| 移动赋值运算符 | |
| promise (const promise &)=delete | |
| 禁止拷贝构造 | |
| promise & | operator= (const promise &)=delete |
| 禁止拷贝赋值 | |
| ~promise () | |
| 析构函数 | |
| void | swap (promise &other) noexcept |
| 交换两个promise对象 | |
| future< Res > | get_future () |
| 获取关联的future对象 | |
| void | set_value (Res &&value) |
| 设置结果值 | |
| void | set_exception (exception_ptr exception) |
| 设置异常 | |
| void | set_value_at_thread_exit (Res &&value) |
| 在线程退出时设置结果值 | |
| void | set_exception_at_thread_exit (exception_ptr exception) |
| 在线程退出时设置异常 | |
Promise类模板
| Res | 结果类型 |
表示一个异步计算的结果提供者,与future配对使用。 可以将计算结果或异常设置到promise中,关联的future可以获取这些结果。
在文件 promise.hpp 第 32 行定义.
|
inline |
默认构造函数
创建新的promise对象,初始化共享状态和结果存储。
在文件 promise.hpp 第 65 行定义.
引用了 _MSTL , 以及 make_shared().
被这些函数引用 operator=(), operator=(), promise< void >::operator=(), promise(), promise() , 以及 swap().
|
inline |
|
inline |
|
inline |
|
inline |
在线程退出时设置结果值
| value | 要设置的结果值 |
| future_exception | 如果结果已被设置 |
在文件 promise.hpp 第 143 行定义.