Guest User

Untitled

a guest
Oct 9th, 2014
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. class server
  2.     {
  3.     public:
  4.         server( unsigned short int thrNum ) :
  5.         {
  6.  
  7.             if( thrNum )
  8.                 threadPool = thrNum;
  9.         };
  10.  
  11.         ~server()
  12.         {
  13.         };
  14.  
  15.         void run()
  16.     {
  17.         std::vector<boost::thread*> threads;
  18.             for(std::size_t i = 0; i < threadPool; ++i)
  19.             {
  20.                 threads.push_back( new boost::thread( boost::bind(&seed::server::pollEvent,this) ) );
  21.             }
  22.  
  23.             for( auto & x : threads )
  24.                     x->join();
  25.  
  26.             for( auto & x : threads )
  27.                     x->detach();
  28.  
  29.             for( auto & x : threads )
  30.                     delete x;
  31.     };
  32.  
  33.     private:
  34.  
  35.         void pollEvent() { return; };
  36.  
  37.         unsigned short int threadPool = 1;
  38.     };
Advertisement
Add Comment
Please, Sign In to add comment