可以使用boost :: asio :: thread_pool代替将boost :: asio :: io_context与boost :: thread :: thread_group结合使用

问题描述 投票:15回答:2

我正在努力消除我的困惑。我偶然发现了boost::asio::thread_pool,我认为有人可以像通常建议的那样自动组合boost::asio::io_contextboost::thread::thread_groupherehere)。看来,asio专用池可用于post任务,但另一方面,某些网络类型(如resolver)需要传递一个对象io_context作为构造函数参数,thread_pool不是,也不是来自。

c++ boost-asio
2个回答
4
投票

假设您有一个名为io_contextioc对象。


2
投票

您应该将io_context.run()发布到thread_pool

© www.soinside.com 2019 - 2024. All rights reserved.