Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. auto hb_interval = seconds(workers_.size());
  2. for (auto& worker : workers_) {
  3.     SharedPtr<high_resolution_timer> hb_timer = std::make_shared<high_resolution_timer>(worker->GetIO(), hb_interval);
  4.     SharedPtr<std::function<void(const boost::system::error_code&)> > cb = std::make_shared<std::function<void(const boost::system::error_code&)> >();
  5.  
  6.     *cb = [this, hb_timer, cb, hb_interval] (const boost::system::error_code& ec) {
  7.         if (ec) {
  8.             return;
  9.         }
  10.  
  11.         hb_timer->expires_after(hb_interval);
  12.         hb_timer->async_wait(*cb);
  13.  
  14.         ++hb_;
  15.     };
  16.  
  17.     hb_timer->async_wait(*cb);
  18.     hb_timers_.push_back(hb_timer);
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement