了解 boost::asio::post 与单个可调用 - 谁执行?
Understanding boost::asio::post with single callable - who executes?
我想知道我应该怎么理解boost::asio::post
特别是这个重载可以只接受一个 callable,who/what/where 现在执行它(因为我没有显式地传递给它一个 io_service
/io_context
例如) ?
它是否只是随机(或多或少)选择一个 运行 io_service
(如果有的话)?我觉得我完全缺少一些东西。
最终,boost::asio::post 将使用 get_associated_executor
查找 associated_executor
. The default implementation will provide a static instance of system_executor
的特化,对象将在其中被调用。
is correct, but if a writer of the code is confused with the default signature, imagine what will happen to a reader! Maybe better to just use this or this 使用显式执行上下文参数重载。
我想知道我应该怎么理解boost::asio::post
特别是这个重载可以只接受一个 callable,who/what/where 现在执行它(因为我没有显式地传递给它一个 io_service
/io_context
例如) ?
它是否只是随机(或多或少)选择一个 运行 io_service
(如果有的话)?我觉得我完全缺少一些东西。
最终,boost::asio::post 将使用 get_associated_executor
查找 associated_executor
. The default implementation will provide a static instance of system_executor
的特化,对象将在其中被调用。