std :: boost :: asio :: post/disp使用哪个io_context? [英] Which io_context does std::boost::asio::post / dispatch use?

查看:580
本文介绍了std :: boost :: asio :: post/disp使用哪个io_context?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用boost :: asio 1.66时,我在文档中读到,boost::asio::post不推荐用于boost::asio::post,与boost::asio::io_context::dispatch相同.因为在它们之前是io_context成员函数的位置,并且当然需要在某些io_context上下文中执行处理程序,即executor我的问题是:

While using boost::asio 1.66 I read in the documentation that boost::asio::io_context::post is deprecated for boost::asio::post, same for boost::asio::io_context::dispatch. Because before they where member functions of the io_context before, and of course the handler needs to be executed in the context of some io_context i.e. executor my question is:

boost :: asio :: io_context :: post最简单的重载如何知道要使用哪个io_contextexecutor?

How does boost::asio::io_context::post simplest overload know which io_context i.e. executor to use?

template< typename CompletionToken> DEDUCED post(CompletionToken && token);的文档指出

通过执行get_associated_executor(handler)获得处理程序的关联执行程序对象ex.

Obtains the handler's associated executor object ex by performing get_associated_executor(handler).

但是get_associated_executor的文档也不清楚.我的猜测是由于 Template参数扣除,它可以以某种方式在当前执行的处理程序中获取它,但是我想确保,而且,如果我在a之外调用post,这还不够. boost :: asio处理程序.

But the documentation of get_associated_executor does not make it clear to me either. My guess is due to the Template argument deduction it can grab it somehow in the currently executed handler, but I want to make sure and also, this wouldn't suffice if I call post outside of a boost::asio handler.

推荐答案

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆