Guest User

Untitled

a guest
Feb 18th, 2014
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <boost/asio.hpp>
  2. #include <boost/thread.hpp>
  3.  
  4. int main(int argc, char* argv[]) {
  5.   for (int i = 0; i < 100000; ++i) {
  6.     std::cout << i << std::endl;
  7.  
  8.     boost::asio::io_service ioService;
  9.     boost::asio::deadline_timer timer(ioService);
  10.  
  11.     ioService.post([&](){
  12.       timer.expires_from_now(boost::posix_time::milliseconds(1));
  13.       timer.async_wait([](const boost::system::error_code &) {});
  14.     });
  15.  
  16.     ioService.post([&](){
  17.       ioService.post([](){});
  18.     });
  19.  
  20.     // Run some threads
  21.     boost::thread_group workers;
  22.     for (auto i=0; i<3; ++i) {
  23.       workers.create_thread([&](){ ioService.run(); });
  24.     }
  25.     workers.join_all();
  26.   }
  27.   return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment