faio
faio 公共 C++ 接口参考
载入中...
搜索中...
未找到
运行时与配置

运行时模式、容量、生命周期与当前协程查询。 更多...

类

class  faio::config_builder
 在运行时启动前构造和验证运行配置。 更多...
class  faio::runtime::config
 由 config_builder::build() 返回的配置值。 更多...
class  faio::anchored_runtime
 为跨实例任务提供目标的独立多线程运行时。 更多...
class  faio::runtime::current_thread_runtime
 由调用线程驱动的独立运行时。 更多...
class  faio::runtime::multi_thread_runtime
 使用多个工作线程的独立运行时。 更多...

类型定义

using faio::ConfigBuilder = config_builder
 config_builder 的兼容名称。

枚举

enum class  faio::runtime::mode { mode::current_thread , mode::multi_thread }
 运行时的调度模式。 更多...
enum class  faio::runtime::blocking_pool_policy { blocking_pool_policy::fixed , blocking_pool_policy::elastic }
 用户阻塞任务池的线程生命周期策略。 更多...
enum class  faio::runtime::io_backend { io_backend::IO_EPOLL , io_backend::IO_URING }
 Linux 编译时选择的 I/O 后端。 更多...
enum class  faio::io::shutdown_policy { shutdown_policy::drain , shutdown_policy::cancel_all }
 运行时的退出策略。 更多...

函数

template<class S, class T>
task< T, S > faio::on (basic_runtime_anchor< S > target, task< T, S > child)
 在指定运行时执行子任务,并把结果交付给来源协程。
void faio::runtime::configure (config options)
 在首次使用前设置默认运行时。
void faio::runtime::shutdown (io::shutdown_policy policy=io::shutdown_policy::drain)
 结束指定方向的 I/O,或按策略关闭运行时。
auto faio::this_coro::stop_token () noexcept
 获取当前对象的协作停止令牌。
auto faio::this_coro::scheduler () noexcept
 查询当前任务所属调度器。
auto faio::this_coro::worker_id () noexcept
 查询当前恢复所在 worker 的编号。
auto faio::this_coro::yield () noexcept
 主动让出执行权并重新入队。
auto faio::this_coro::yield_if_needed () noexcept
 依据协作预算决定是否让出执行权。

详细描述

运行时模式、容量、生命周期与当前协程查询。

枚举类型说明

◆ mode

enum class faio::runtime::mode
strong

运行时的调度模式。

枚举值
current_thread 

在当前线程驱动任务。

multi_thread 

在多个 worker 上调度任务。

◆ blocking_pool_policy

用户阻塞任务池的线程生命周期策略。

枚举值
fixed 

构造时预热全部线程,关闭时回收。

elastic 

按需创建线程,空闲超时后回收。

◆ io_backend

enum class faio::runtime::io_backend
strong

Linux 编译时选择的 I/O 后端。

枚举值
IO_EPOLL 

epoll 后端。

IO_URING 

io_uring 后端。

◆ shutdown_policy

enum class faio::io::shutdown_policy
strong

运行时的退出策略。

枚举值
drain 

等待已接受任务排空;任务需有退出路径。

cancel_all 

先请求任务停止,再等待排空。

函数说明

◆ on()

template<class S, class T>
task< T, S > faio::on ( basic_runtime_anchor< S > target,
task< T, S > child )

在指定运行时执行子任务,并把结果交付给来源协程。

参数
target目标 anchored_runtime 的 anchor() 返回的凭据。
child移动提交的惰性子任务;提交后调用方不再拥有它。
返回
等待后取得子任务的值或异常。

◆ configure()

void faio::runtime::configure ( config options)

在首次使用前设置默认运行时。

参数
options本次操作的选项值,默认值保持当前接口声明所示行为。
返回值
无返回值;成功后首次 block_on/spawn 使用此配置。
注解
已启动或已经关闭时抛 logic_error;非法配置会被拒绝。

◆ shutdown()

void faio::runtime::shutdown ( io::shutdown_policy policy = io::shutdown_policy::drain)

结束指定方向的 I/O,或按策略关闭运行时。

参数
policy运行时关闭策略,默认 drain;常驻任务仍需有退出路径。 默认值:io::shutdown_policy::drain。
返回值
I/O 对象等待后得到 expected<void>;runtime::shutdown 为同步无返回值。

◆ stop_token()

auto faio::this_coro::stop_token ( )
noexcept

获取当前对象的协作停止令牌。

返回
返回 std::stop_token;this_coro 查询需 co_await 才取得当前任务令牌。
错误与异常
返回 expected 的重载以 error() 报告失败;先检查成功状态再读取值。任务中的异常沿等待链传播。

◆ scheduler()

auto faio::this_coro::scheduler ( )
noexcept

查询当前任务所属调度器。

返回
co_await 后取得借用的调度器引用,不拥有运行时。
错误与异常
返回 expected 的重载以 error() 报告失败;先检查成功状态再读取值。任务中的异常沿等待链传播。

◆ worker_id()

auto faio::this_coro::worker_id ( )
noexcept

查询当前恢复所在 worker 的编号。

返回
co_await 后取得本次恢复的 worker id。
注解
协程可能迁移,不能将此值当作永久线程身份。
错误与异常
返回 expected 的重载以 error() 报告失败;先检查成功状态再读取值。任务中的异常沿等待链传播。

◆ yield()

auto faio::this_coro::yield ( )
noexcept

主动让出执行权并重新入队。

返回
co_await 后在下一次调度继续,无业务返回值。
错误与异常
返回 expected 的重载以 error() 报告失败;先检查成功状态再读取值。任务中的异常沿等待链传播。

◆ yield_if_needed()

auto faio::this_coro::yield_if_needed ( )
noexcept

依据协作预算决定是否让出执行权。

返回
co_await 后继续执行,无业务返回值。
错误与异常
返回 expected 的重载以 error() 报告失败;先检查成功状态再读取值。任务中的异常沿等待链传播。