std :: boost :: asio :: post/disp使用哪个io_context? [英] Which io_context does std::boost::asio::post / dispatch use?
问题描述
使用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_context
即executor
?
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.