我为接受器(侦听器)使用了一个由十个线程组成的池,它们接受连接并在其他线程中运行它们的处理任务。在这种情况下,我需要一个或多个接受器对象吗?
{
boost::asio::io_service io_service_acceptors;
boost::asio::io_service::work work_acceptors(io_service_acceptors);
// Do I need a single object or many like threads "thr_grp_acceptors"?:
// std::vector<boost::asio::ip::tcp::acceptor> acpt_grp_acceptors
boost::asio::ip::tcp::acceptor acceptor(io_service_acceptors,
ba::ip::tcp::endpoint(ba::ip::tcp::v4(), port));
std::vector<boost::thread> thr_grp_acceptors;
for(size_t i = 0; i < 10; ++i)
thr_grp_acceptors_.emplace_back(
boost::bind(&boost::asio::io_service::run, &io_service_acceptors));
acceptor_.async_accept(...);
}