Added thread_num

This commit is contained in:
nik012003
2022-06-26 13:29:54 +02:00
committed by DomySh
parent 01edd3c2fc
commit 2d5b566b8e
2 changed files with 11 additions and 3 deletions

View File

@@ -17,7 +17,7 @@
//#define MULTI_THREAD
//#define DEBUG
//#define DEBUG_PACKET
//#define THREAD_NUM
using namespace std;
boost::asio::io_service *ios_loop = nullptr;
@@ -459,7 +459,11 @@ int main(int argc, char* argv[])
acceptor.accept_connections();
#ifdef MULTI_THREAD
boost::thread_group tg;
#ifdef THREAD_NUM
for (unsigned i = 0; i < THREAD_NUM; ++i)
#else
for (unsigned i = 0; i < thread::hardware_concurrency(); ++i)
#endif
tg.create_thread(boost::bind(&boost::asio::io_service::run, &ios));
tg.join_all();