NexusForce 1.0.0
A rigorously engineered full-stack C++ backend library.
载入中...
搜索中...
未找到
协程启动

在 executor 上启动协程 更多...

struct  neforce::co_spawn_task
 co_spawn 使用的协程任务类型 更多...

函数

template<typename Executor, typename Func>
void neforce::co_spawn (Executor &&exec, Func func)
 在 executor 上启动协程

详细描述

在 executor 上启动协程

函数说明

◆ co_spawn()

template<typename Executor, typename Func>
void neforce::co_spawn ( Executor && exec,
Func func )

在 executor 上启动协程

模板参数
Executor执行器类型
Func返回 awaitable 的可调用对象
参数
exec执行器(如 io_context::executor 或 strand)
func协程工厂函数,返回 awaitable
co_spawn(ctx.get_executor(), [&]() -> awaitable<void> {
auto n = co_await sock.async_receive(buf, use_awaitable);
println("read ", n, " bytes");
});
可被 co_await 的异步操作结果
void co_spawn(Executor &&exec, Func func)
在 executor 上启动协程

在文件 co_spawn.hpp73 行定义.

引用了 co_spawn().

被这些函数引用 co_spawn().