faio
faio 公共 C++ 接口参考
载入中...
搜索中...
未找到
faio::task_outcome< T > 模板类 参考

保存任务的成功值、异常或协作停止原因。 更多...

Public 成员函数

task_outcome_status status () const noexcept
 读取任务终态。
std::optional< task_stop_reason > stop_reason () const noexcept
 读取停止时的原因。
std::exception_ptr exception () const noexcept
 读取任务保存的异常。
T take_value ()
 领取一次成功值。
T value_or_throw ()
 领取成功值,或按终态抛出异常。

详细描述

template<class T>
class faio::task_outcome< T >

保存任务的成功值、异常或协作停止原因。

公共头文件
#include <faio/coroutine/composition.hpp>

成员函数说明

◆ status()

template<class T>
task_outcome_status faio::task_outcome< T >::status ( ) const
noexcept

读取任务终态。

返回
返回 value、error 或 stopped。

◆ stop_reason()

template<class T>
std::optional< task_stop_reason > faio::task_outcome< T >::stop_reason ( ) const
noexcept

读取停止时的原因。

返回
返回可选的 task_stop_reason。

◆ exception()

template<class T>
std::exception_ptr faio::task_outcome< T >::exception ( ) const
noexcept

读取任务保存的异常。

返回
返回异常指针,没有记录异常时为空。

◆ take_value()

template<class T>
T faio::task_outcome< T >::take_value ( )

领取一次成功值。

返回
返回 T,void 无业务值。没有可领取的成功值时抛出异常。

◆ value_or_throw()

template<class T>
T faio::task_outcome< T >::value_or_throw ( )

领取成功值,或按终态抛出异常。

返回
返回 T,void 无业务值。失败时重抛原异常。