我的问题是关于提升asio的io_service。 当我与该方法调用它:从线程池中调用时,boost的io_service共享线程是否为请求?
int main()
{
try
{
boost::asio::io_service io_service;
Server server(io_service);
std::vector<boost::shared_ptr<boost::thread> > threads;
for (std::size_t i = 0; i < 16; ++i)
{
boost::shared_ptr<boost::thread> thread(new boost::thread(boost::bind(&boost::asio::io_service::run, &io_service)));
threads.push_back(thread);
}
for (std::size_t i = 0; i < threads.size(); ++i)
threads[i]->join();
}
catch (std::exception& e)
{
std::cerr << e.what() << std::endl;
}
return 0;
}
将它分享给请求的线程动态,或将只给只有一个线程用于连接组? 谢谢。
您能否澄清当前上下文中的“请求”和“连接组”? –
@IvanGrynko我的意思是请求处理程序处理接收到的数据包的服务器逻辑。每个调度连接信号的连接组意味着与反应堆模式1线程相似。 – user2971678