10 asio::co_spawn(context_, std::move(task), [
this](std::exception_ptr error) {
12 handle_unhandled_exception(error,
"coroutine");
73 if (shutdown_started_) {
76 shutdown_started_ =
true;
78 if (!shutdown_handler_) {
87 auto shutdown_task = shutdown_handler_();
89 context_, std::move(shutdown_task),
90 [
this](std::exception_ptr shutdown_error) {
91 finish_shutdown(shutdown_error);
94 finish_shutdown(std::current_exception());
void request_shutdown() noexcept
请求一次安全停机。
bool init(info_type _info)
初始化 task_context
void spawn(task_type &&task)
添加一个协程任务到上下文中执行。
void set_shutdown_handler(shutdown_handler_type handler)
注册异常或外部请求共用的一次性安全停机任务。