예제 #1
0
  /**
   * \brief Adds the future to the barrier.
   * \return Whether the future could be added.
   *
   * \verbatim
   * This adds the future to the barrier. It means barrier's future won't return
   * until this one returns. It will also be added to the resulting vector.
   *
   * When :cpp:func:`qi::FutureBarrier::future()` has been called, this function
   * will throw.
   * \endverbatim
   */
  void addFuture(qi::Future<T> fut) {
    // Can't add future from closed qi::FutureBarrier.
    if (*_p->_closed)
      throw std::runtime_error("Adding future to closed barrier");

    ++(_p->_count);
    fut.connect(boost::bind<void>(&detail::FutureBarrierPrivate<T>::onFutureFinish, _p));
    _p->_futures.push_back(fut);
  }
예제 #2
0
 void PeriodicTaskPrivate::_reschedule(qi::Duration delay)
 {
   qiLogDebug() << "rescheduling in " << qi::to_string(delay);
   if (_scheduleCallback)
     _task = _scheduleCallback(boost::bind(&PeriodicTaskPrivate::_wrap, shared_from_this()), delay);
   else
     _task = getEventLoop()->asyncDelay(boost::bind(&PeriodicTaskPrivate::_wrap, shared_from_this()), delay);
   _state = TaskState::Scheduled;
   _task.connect(boost::bind(
         &PeriodicTaskPrivate::_onTaskFinished, shared_from_this(), _1));
 }