示例#1
0
   void fire(AsyncCall func, Args&& ... args) const noexcept(false) {

      if (empty()) {
         throw std::runtime_error("nullptr instantiated worker");
      }
      // weak compiler support for expanding parameter pack in a lambda. std::function is the
      // work-around, With better compiler support it can be changed to:
      //       auto bgCall = [&, args...]{ return (_worker.*func)(args...); };
      auto bgCall = std::bind(func, _worker.get(), std::forward<Args>(args)...);
      _q.push(bgCall);
      return;
   }
示例#2
0
 /**
  * Clean shutdown. All pending messages are executed before the shutdown message is received
  */
 virtual ~concurrent() {
    _q.push([ = ] {_done = true;});
    if (_thd.joinable()) {
       _thd.join();
    }
 }
示例#3
0
文件: main.cpp 项目: CCJY/coliru
 ~concurrent() {
    _q.push([ = ]{_done = true;});
    _thd.join();
 }