libqi-api  2.4.3.28
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
future_fwd.hpp
Go to the documentation of this file.
1 #pragma once
2 /*
3 ** Copyright (C) 2012 Aldebaran Robotics
4 ** See COPYING for the license
5 */
6 
7 #ifndef _QI_FUTURE_HPP_
8 # define _QI_FUTURE_HPP_
9 
10 # include <qi/api.hpp>
11 # include <vector>
12 # include <qi/atomic.hpp>
13 # include <qi/config.hpp>
14 # include <qi/trackable.hpp>
15 # include <qi/clock.hpp>
16 # include <qi/detail/mpl.hpp>
17 # include <qi/anyvalue.hpp>
18 
19 # include <boost/shared_ptr.hpp>
20 # include <boost/make_shared.hpp>
21 # include <boost/function.hpp>
22 # include <boost/bind.hpp>
23 # include <boost/thread/recursive_mutex.hpp>
24 
25 # ifdef _MSC_VER
26 # pragma warning( push )
27 # pragma warning( disable: 4251 )
28 # pragma warning( disable: 4275 ) //std::runtime_error: no dll interface
29 # endif
30 
31 namespace qi {
32 
33  class AnyReference;
34 
35  namespace detail
36  {
37  template<typename T>
38  struct FutureType
39  {
40  typedef T type;
41  typedef T typecast;
42  };
43 
44  struct FutureHasNoValue {};
45  // Hold a void* for Future<void>
46  template<>
47  struct FutureType<void>
48  {
49  typedef void* type;
51  };
52 
53  template <typename T>
54  class AddUnwrap
55  {};
56  }
57 
58  class Actor;
59  class Strand;
60 
61  template <typename T> class Future;
62  template <typename T> class FutureSync;
63  template <typename T> class Promise;
64 
65  namespace detail {
66  template <typename T> class FutureBaseTyped;
67 
68  template<typename FT>
70  boost::weak_ptr<detail::FutureBaseTyped<FT> > wf);
71  }
72 
75  enum FutureState {
81  };
82 
86  };
87 
89  FutureTimeout_Infinite = ((int) 0x7fffffff),
91  };
92 
93  typedef void* FutureUniqueId;
94 
97  class QI_API FutureException : public std::runtime_error {
98  public:
106  };
107 
108  explicit FutureException(const ExceptionState &es, const std::string &str = std::string())
109  : std::runtime_error(stateToString(es) + str)
110  , _state(es)
111  {}
112 
113  inline ExceptionState state() const { return _state; }
114 
115  std::string stateToString(const ExceptionState &es);
116 
117  virtual ~FutureException() throw()
118  {}
119 
120  private:
121  ExceptionState _state;
122  };
123 
128  public:
129 
130  explicit FutureUserException(const std::string &str = std::string())
131  : FutureException(ExceptionState_FutureUserError, str)
132  {}
133 
134  virtual ~FutureUserException() throw()
135  {}
136  };
137 
142  template <typename T>
143  class Future : public detail::AddUnwrap<T> {
144  public:
147 
148  public:
150  : _p(boost::make_shared<detail::FutureBaseTyped<T> >())
151  {
152  }
153 
154  Future(const Future<T>& b)
155  : _p(b._p)
156  {}
157 
158  bool operator==(const Future<T> &other)
159  {
160  return _p.get() == other._p.get();
161  }
162 
163  inline Future<T>& operator=(const Future<T>& b)
164  {
165  _p = b._p;
166  return *this;
167  }
168 
169  bool operator < (const Future<T>& b) const
170  {
171  return _p.get() < b._p.get();
172  }
173 
175  {
176  return _p.get();
177  }
178 
182  {
183  Promise<T> promise(async);
184  promise.setValue(v);
185  *this = promise.future();
186  }
187 
200  inline const ValueType &value(int msecs = FutureTimeout_Infinite) const
201  { return _p->value(msecs); }
202 
205  inline operator const ValueTypeCast&() const
206  { return _p->value(FutureTimeout_Infinite); }
207 
212  inline FutureState wait(int msecs = FutureTimeout_Infinite) const
213  { return _p->wait(msecs); }
214 
219  inline FutureState wait(qi::Duration duration) const
220  { return _p->wait(duration); }
221 
222  inline FutureState waitFor(qi::Duration duration) const
223  { return this->wait(duration); }
224 
230  { return _p->wait(timepoint); }
231 
233  { return this->wait(timepoint); }
234 
239  inline bool isFinished() const
240  { return _p->isFinished(); }
241 
246  inline bool isRunning() const
247  { return _p->isRunning(); }
248 
255  inline bool isCanceled() const
256  { return _p->isCanceled(); }
257 
264  inline bool hasError(int msecs = FutureTimeout_Infinite) const
265  { return _p->hasError(msecs); }
266 
274  inline bool hasValue(int msecs = FutureTimeout_Infinite) const
275  { return _p->hasValue(msecs); }
276 
283  inline const std::string &error(int msecs = FutureTimeout_Infinite) const
284  { return _p->error(msecs); }
285 
290  {
291  return FutureSync<T>(*this);
292  };
293 
300  void cancel()
301  {
302  _p->cancel(*this);
303  }
304 
308  bool isCancelable() const
309  {
310  return _p->isCancelable();
311  }
312 
313  template <typename R>
315  FutureCallbackType type,
316  const boost::function<R(const Future<T>&)>& func);
317 
318  template <typename R>
320  const boost::function<R(const Future<T>&)>& func)
321  {
322  return this->thenR(FutureCallbackType_Async, func);
323  }
324 
325  template <typename R>
327  FutureCallbackType type,
328  const boost::function<R(const typename Future<T>::ValueType&)>& func);
329 
330  template <typename R>
332  const boost::function<R(const typename Future<T>::ValueType&)>& func)
333  {
334  return this->andThenR(FutureCallbackType_Async, func);
335  }
336 
337 #define genCall(n, ATYPEDECL, ATYPES, ADECL, AUSE, comma) \
338  template <typename R, typename AF, typename ARG0 comma ATYPEDECL> \
339  Future<R> thenR(const AF& func, const ARG0& arg0 comma ADECL) \
340  { \
341  return this->thenR<R>(FutureCallbackType_Async, func, arg0 comma AUSE); \
342  } \
343  template <typename R, typename AF, typename ARG0 comma ATYPEDECL> \
344  Future<R> thenR(FutureCallbackType type, const AF& func, \
345  const ARG0& arg0 comma ADECL) \
346  { \
347  return _thenMaybeActor<R, ARG0>( \
348  arg0, ::qi::bind<R(const Future<T>&)>(func, arg0 comma AUSE), type); \
349  }
350  QI_GEN(genCall)
351 #undef genCall
352 
361  boost::function<void()> makeCanceler();
362 
363  public:
364  typedef boost::function<void (Future<T>) > Connection;
365 
375  template<typename AF>
376  inline void connect(const AF& fun,
378  {
379  _p->connect(*this, fun, type);
380  }
381 #ifdef DOXYGEN
382 
388  template<typename FUNCTYPE, typename ARG0>
389  void connect(FUNCTYPE fun, ARG0 tracked, ...,
391 #else
392 #define genCall(n, ATYPEDECL, ATYPES, ADECL, AUSE, comma) \
393  template <typename AF, typename ARG0 comma ATYPEDECL> \
394  inline void connect(const AF& fun, const ARG0& arg0 comma ADECL, \
395  FutureCallbackType type = FutureCallbackType_Async) \
396  { \
397  _connectMaybeActor<ARG0>( \
398  arg0, ::qi::bind<void(Future<T>)>(fun, arg0 comma AUSE), type); \
399  }
400  QI_GEN(genCall)
401 #undef genCall
402 #endif
403 
404  inline void connectWithStrand(qi::Strand* strand,
405  const boost::function<void(const Future<T>&)>& cb)
406  {
407  _p->connect(
408  *this,
409  transformStrandedCallback(strand, cb),
411  }
412 
413  // Our companion library libqitype requires a connect with same signature for all instantiations
414  inline void _connect(const boost::function<void()>& s)
415  {
416  connect(boost::bind(s));
417  }
418 
419  boost::shared_ptr<detail::FutureBaseTyped<T> > impl() { return _p;}
420  Future(boost::shared_ptr<detail::FutureBaseTyped<T> > p) :
421  _p(p)
422  {
423  assert(_p);
424  }
425 
426  protected:
427  // C4251 needs to have dll-interface to be used by clients of class 'qi::Future<T>'
428  boost::shared_ptr< detail::FutureBaseTyped<T> > _p;
429  friend class Promise<T>;
430  friend class FutureSync<T>;
431 
432  template<typename R>
434  template<typename FT, typename PT>
435  friend void adaptFuture(const Future<FT>& f, Promise<PT>& p);
436  template<typename FT, typename PT, typename CONV>
437  friend void adaptFuture(const Future<FT>& f, Promise<PT>& p,
438  CONV converter);
439  template<typename R>
440  friend void adaptFuture(Future<AnyReference>& f, Promise<R>& p);
441 
442  template<typename FT>
443  friend void detail::futureCancelAdapter(
444  boost::weak_ptr<detail::FutureBaseTyped<FT> > wf);
445  friend class detail::AddUnwrap<T>;
446 
447  private:
448  friend class ServiceBoundObject;
449 
450  // Nuke this when C++03 ends
451  void setOnDestroyed(boost::function<void(ValueType)> cb)
452  {
453  _p->setOnDestroyed(cb);
454  }
455 
456  template <typename Arg>
457  static void binder(
458  const boost::function<void(const boost::function<void()>&)>& poster,
459  const boost::function<void(const Arg&)>& callback, const Arg& fut);
460 
461  template <typename Arg>
462  boost::function<void(const Arg&)> transformStrandedCallback(
463  qi::Strand* strand,
464  const boost::function<void(const Arg&)>& cb);
465 
466  template <typename ARG0>
467  typename boost::enable_if<
468  boost::is_base_of<Actor, typename detail::Unwrap<ARG0>::type>,
469  void>::type
470  _connectMaybeActor(const ARG0& arg0,
471  const boost::function<void(const Future<T>&)>& cb,
472  FutureCallbackType type);
473  template <typename ARG0>
474  typename boost::disable_if<
475  boost::is_base_of<Actor, typename detail::Unwrap<ARG0>::type>,
476  void>::type
477  _connectMaybeActor(const ARG0& arg0,
478  const boost::function<void(const Future<T>&)>& cb,
479  FutureCallbackType type);
480 
481  template <typename R>
482  static void _continuate(const Future<T>& future,
483  const boost::function<R(const Future<T>&)>& func,
484  Promise<R>& promise);
485 
486  static void _cancelContinuation(const Future<T>& future,
487  Promise<T>& promise);
488 
489  template <typename R, typename ARG0, typename AF>
490  typename boost::enable_if<
491  boost::is_base_of<Actor, typename detail::Unwrap<ARG0>::type>,
492  qi::Future<R> >::type
493  _thenMaybeActor(const ARG0& arg0,
494  const AF& cb,
495  FutureCallbackType type);
496  template <typename R, typename ARG0, typename AF>
497  typename boost::disable_if<
498  boost::is_base_of<Actor, typename detail::Unwrap<ARG0>::type>,
499  qi::Future<R> >::type
500  _thenMaybeActor(const ARG0& arg0,
501  const AF& cb,
502  FutureCallbackType type);
503 
504  static void _weakCancelCb(const boost::weak_ptr<detail::FutureBaseTyped<T> >& wfuture);
505  };
506 
515  template<typename T>
516  class FutureSync
517  {
518  public:
519  typedef typename Future<T>::ValueType ValueType;
522  // This future cannot be set, so sync starts at false
523  FutureSync() : _sync(false) {}
524 
526  : _sync(true)
527  {
528  _future = b;
529  }
530 
532  : _sync(true)
533  {
534  _future = b._future;
535  b._sync = false;
536  }
537 
538  explicit FutureSync<T>(const ValueType& v)
539  : _sync(false)
540  {
541  Promise<T> promise;
542  promise.setValue(v);
543  _future = promise.future();
544  }
545 
547  {
548  _future = b;
549  _sync = true;
550  b._sync = false;
551  return *this;
552  }
553 
555  {
556  _future = b;
557  _sync = true;
558  return *this;
559  }
560 
565  {
566  if (_sync)
567  _future.value();
568  }
569 
570  operator Future<T>()
571  {
572  return async();
573  }
574 
575  bool operator < (const FutureSync<T>& b) const
576  {
577  return _future._p.get() < b._future._p.get();
578  }
579 
581  {
582  return _future.uniqueId();
583  }
584 
585  const ValueType &value(int msecs = FutureTimeout_Infinite) const { _sync = false; return _future.value(msecs); }
586  operator const typename Future<T>::ValueTypeCast&() const { _sync = false; return _future.value(); }
587  FutureState wait(int msecs = FutureTimeout_Infinite) const { _sync = false; return _future.wait(msecs); }
588  FutureState wait(qi::Duration duration) const { _sync = false; return _future.wait(duration); }
589  FutureState waitFor(qi::Duration duration) const { _sync = false; return _future.waitFor(duration); }
590  FutureState wait(qi::SteadyClock::time_point timepoint) const { _sync = false; return _future.wait(timepoint); }
591  FutureState waitUntil(qi::SteadyClock::time_point timepoint) const { _sync = false; return _future.waitUntil(timepoint); }
592  bool isRunning() const { _sync = false; return _future.isRunning(); }
593  bool isFinished() const { _sync = false; return _future.isFinished(); }
594  bool isCanceled() const { _sync = false; return _future.isCanceled(); }
595  bool hasError(int msecs = FutureTimeout_Infinite) const { _sync = false; return _future.hasError(msecs); }
596  bool hasValue(int msecs = FutureTimeout_Infinite) const { _sync = false; return _future.hasValue(msecs); }
597  const std::string &error(int msecs = FutureTimeout_Infinite) const { _sync = false; return _future.error(msecs); }
598  void cancel() { _sync = false; _future.cancel(); }
599  bool isCancelable() const { _sync = false; return _future.isCancelable(); }
600  void connect(const Connection& s) { _sync = false; _future.connect(s);}
601  void _connect(const boost::function<void()>& s) { _sync = false; _future._connect(s);}
602 
603 #ifdef DOXYGEN
604 
610  template<typename FUNCTYPE, typename ARG0>
611  void connect(FUNCTYPE fun, ARG0 tracked, ...);
612 #else
613 #define genCall(n, ATYPEDECL, ATYPES, ADECL, AUSE, comma) \
614  template<typename AF, typename ARG0 comma ATYPEDECL> \
615  inline void connect(const AF& fun, const ARG0& arg0 comma ADECL) \
616  { \
617  _sync = false; \
618  connect(::qi::bind<void(FutureSync<T>)>(fun, arg0 comma AUSE)); \
619  }
620  QI_GEN(genCall)
621 #undef genCall
622 #endif
623 
625  {
626  _sync = false;
627  return _future;
628  }
629 
630  protected:
631  mutable bool _sync;
633  friend class Future<T>;
634  };
635 
640  template <typename T>
641  class Promise {
642  public:
644 
651  _f._p->reportStart();
652  _f._p->_async = async;
653  ++_f._p->_promiseCount;
654  }
655 
661  explicit Promise(boost::function<void (qi::Promise<T>)> cancelCallback,
663  {
664  setup(cancelCallback, async);
665  ++_f._p->_promiseCount;
666  }
667 
669  {
670  _f = rhs._f;
671  ++_f._p->_promiseCount;
672  }
673 
675  decRefcnt();
676  }
677 
682  void setValue(const ValueType &value) {
683  _f._p->setValue(_f, value);
684  }
685 
689  void setError(const std::string &msg) {
690  _f._p->setError(_f, msg);
691  }
692 
696  void setCanceled() {
697  _f._p->setCanceled(_f);
698  }
699 
703  bool isCancelRequested() const {
704  return _f._p->isCancelRequested();
705  }
706 
708  Future<T> future() const { return _f; }
709 
714  ValueType& value() { return _f._p->_value;}
717  void trigger() { _f._p->set(_f);}
718 
724  void setOnCancel(boost::function<void (qi::Promise<T>)> cancelCallback)
725  {
726  if (!this->_f._p->isCancelable())
727  throw std::runtime_error("Promise was not created as a cancelable one");
728  qi::Future<T> fut = this->future();
729  this->_f._p->setOnCancel(*this, cancelCallback);
730  }
731 
733  {
734  if (_f._p == rhs._f._p)
735  return *this;
736 
737  decRefcnt();
738  _f = rhs._f;
739  ++_f._p->_promiseCount;
740  return *this;
741  }
742 
743  protected:
744  void setup(boost::function<void (qi::Promise<T>)> cancelCallback, FutureCallbackType async = FutureCallbackType_Async)
745  {
746  this->_f._p->reportStart();
747  this->_f._p->setOnCancel(*this, cancelCallback);
748  this->_f._p->_async = async;
749  }
750  explicit Promise(Future<T>& f) : _f(f) {
751  ++_f._p->_promiseCount;
752  }
753  template<typename> friend class ::qi::detail::FutureBaseTyped;
755 
756  template<typename R>
758  template<typename FT, typename PT>
759  friend void adaptFuture(const Future<FT>& f, Promise<PT>& p);
760  template<typename FT, typename PT, typename CONV>
761  friend void adaptFuture(const Future<FT>& f, Promise<PT>& p,
762  CONV converter);
763  template<typename R>
764  friend void adaptFuture(Future<AnyReference>& f, Promise<R>& p);
765 
766  private:
767  void decRefcnt()
768  {
769  assert(*_f._p->_promiseCount > 0);
770  // this is race-free because if we reach 0 it means that this is the last Promise pointing to a state and since it
771  // is the last, no one could be trying to make a copy from it while destroying it. Also no one could be changing
772  // the promise state (from running to finished or whatever) while destroying it.
773  if (--_f._p->_promiseCount == 0 && _f.isRunning())
774  _f._p->setBroken(_f);
775  }
776  };
777 
782  template <typename T>
783  qi::Future<T> makeFutureError(const std::string& error);
784 
786  template <typename T>
788  {
789  }
790 
792  template<typename FT, typename PT>
794  {
795  void operator()(const FT& vIn, PT& vOut) { vOut = vIn;}
796  };
797 
801  template<typename R>
802  void adaptFutureUnwrap(Future<AnyReference>& f, Promise<R>& p);
803 
811  template<typename FT, typename PT>
812  void adaptFuture(const Future<FT>& f, Promise<PT>& p);
813 
814  template<typename R>
815  void adaptFuture(Future<AnyReference>& f, Promise<R>& p);
816 
818  template<typename FT, typename PT, typename CONV>
819  void adaptFuture(const Future<FT>& f, Promise<PT>& p, CONV converter);
820 
822  template <typename T>
823  inline boost::function<void()> makeCanceler(Future<T>& future)
824  {
825  return future.makeCanceler();
826  }
827 }
828 
829 #ifdef _MSC_VER
830 # pragma warning( pop )
831 #endif
832 
833 #endif // _QI_FUTURE_HPP_
Future< T >::ValueTypeCast ValueTypeCast
Definition: future_fwd.hpp:520
FutureSync< T > sync()
Definition: future_fwd.hpp:289
asked for error, but there is no error
Definition: future_fwd.hpp:103
Promise(FutureCallbackType async=FutureCallbackType_Async)
Definition: future_fwd.hpp:650
void operator()(const FT &vIn, PT &vOut)
Definition: future_fwd.hpp:795
Future< T > _future
Definition: future_fwd.hpp:632
bool operator==(const Future< T > &other)
Definition: future_fwd.hpp:158
The future has been canceled.
Definition: future_fwd.hpp:78
friend void adaptFuture(const Future< FT > &f, Promise< PT > &p)
Feed a promise from a future of possibly different type.
Definition: future.hxx:621
#define QI_API
Definition: api.hpp:34
void PromiseNoop(qi::Promise< T > &)
Helper function that does nothing on future cancelation.
Definition: future_fwd.hpp:787
FutureTimeout
Definition: future_fwd.hpp:88
boost::function< RF > bind(const AF &fun,...)
void connect(const Connection &s)
Definition: future_fwd.hpp:600
boost::chrono::duration< int64_t, boost::nano > Duration
Convenience typedefs.
Definition: clock.hpp:18
FutureState waitFor(qi::Duration duration) const
Definition: future_fwd.hpp:589
void setup(boost::function< void(qi::Promise< T >)> cancelCallback, FutureCallbackType async=FutureCallbackType_Async)
Definition: future_fwd.hpp:744
void _connect(const boost::function< void()> &s)
Definition: future_fwd.hpp:414
friend void adaptFutureUnwrap(Future< AnyReference > &f, Promise< R > &p)
Feed a promise from a generic future which may be unwrapped if it contains itself a future...
Definition: future.hxx:610
Future< T >::ValueType ValueType
Definition: future_fwd.hpp:519
Promise(boost::function< void(qi::Promise< T >)> cancelCallback, FutureCallbackType async=FutureCallbackType_Async)
Definition: future_fwd.hpp:661
void setError(const std::string &msg)
Definition: future_fwd.hpp:689
FutureState wait(qi::Duration duration) const
Definition: future_fwd.hpp:588
ValueType & value()
Definition: future_fwd.hpp:714
friend void adaptFutureUnwrap(Future< AnyReference > &f, Promise< R > &p)
Feed a promise from a generic future which may be unwrapped if it contains itself a future...
Definition: future.hxx:610
Promise(Future< T > &f)
Definition: future_fwd.hpp:750
ExceptionState state() const
Definition: future_fwd.hpp:113
const ValueType & value(int msecs=FutureTimeout_Infinite) const
Definition: future_fwd.hpp:585
bool isCanceled() const
Definition: future_fwd.hpp:594
FutureUserException(const std::string &str=std::string())
Definition: future_fwd.hpp:130
FutureState wait(qi::SteadyClock::time_point timepoint) const
Definition: future_fwd.hpp:229
dll import/export and compiler message
bool isCanceled() const
Definition: future_fwd.hpp:255
FutureSync(const Future< T > &b)
Definition: future_fwd.hpp:525
boost::function< void()> makeCanceler()
Get a functor that will cancel the future.
Definition: future.hxx:230
void trigger()
Definition: future_fwd.hpp:717
Specialize this struct to provide conversion between future values.
Definition: future_fwd.hpp:793
qi::Future< T > makeFutureError(const std::string &error)
Helper function to return a future with the error set.
Definition: future.hxx:548
void _connect(const boost::function< void()> &s)
Definition: future_fwd.hpp:601
const std::string & error(int msecs=FutureTimeout_Infinite) const
Definition: future_fwd.hpp:597
bool isCancelRequested() const
Definition: future_fwd.hpp:703
#define QI_NOEXCEPT(cond)
Specify that a function may throw or not.
Definition: macro.hpp:292
Future< T > _f
Definition: future_fwd.hpp:754
void connect(const AF &fun, FutureCallbackType type=FutureCallbackType_Async)
Definition: future_fwd.hpp:376
Future< T > future() const
Get a future linked to this promise. Can be called multiple times.
Definition: future_fwd.hpp:708
Future< R > andThenR(const boost::function< R(const typename Future< T >::ValueType &)> &func)
Definition: future_fwd.hpp:331
boost::shared_ptr< detail::FutureBaseTyped< T > > _p
Definition: future_fwd.hpp:428
boost::function< void(Future< void >) > Connection
Definition: future_fwd.hpp:364
virtual ~FutureUserException()
Definition: future_fwd.hpp:134
Future< R > async(boost::function< R()> callback, uint64_t usDelay=0)
Definition: eventloop.hpp:176
FutureState
Definition: future_fwd.hpp:75
FutureState wait(qi::SteadyClock::time_point timepoint) const
Definition: future_fwd.hpp:590
friend class ServiceBoundObject
Definition: future_fwd.hpp:448
Future< T > async()
Definition: future_fwd.hpp:624
Future is not tied to a promise.
Definition: future_fwd.hpp:76
boost::function< void()> makeCanceler(Future< T > &future)
Definition: future_fwd.hpp:823
Operation pending.
Definition: future_fwd.hpp:77
#define genCall(n, ATYPEDECL, ATYPES, ADECL, AUSE, comma)
Definition: future_fwd.hpp:337
FutureState waitUntil(qi::SteadyClock::time_point timepoint) const
Definition: future_fwd.hpp:591
detail::FutureType< T >::typecast ValueTypeCast
Definition: future_fwd.hpp:146
FutureException(const ExceptionState &es, const std::string &str=std::string())
Definition: future_fwd.hpp:108
~FutureSync() QI_NOEXCEPT(false)
Definition: future_fwd.hpp:564
void setOnCancel(boost::function< void(qi::Promise< T >)> cancelCallback)
Definition: future_fwd.hpp:724
bool isCancelable() const
Definition: future_fwd.hpp:308
bool isRunning() const
Definition: future_fwd.hpp:246
void cancel()
Definition: future_fwd.hpp:300
Future(const Future< T > &b)
Definition: future_fwd.hpp:154
detail::FutureType< T >::type ValueType
Definition: future_fwd.hpp:643
FutureState wait(qi::Duration duration) const
Definition: future_fwd.hpp:219
bool isCancelable() const
Definition: future_fwd.hpp:599
The operation is finished with an error.
Definition: future_fwd.hpp:79
FutureSync< T > & operator=(const Future< T > &b)
Definition: future_fwd.hpp:554
detail::FutureType< T >::type ValueType
Definition: future_fwd.hpp:145
FutureState waitFor(qi::Duration duration) const
Definition: future_fwd.hpp:222
bool isRunning() const
Definition: future_fwd.hpp:592
void setCanceled()
Definition: future_fwd.hpp:696
FutureState wait(int msecs=FutureTimeout_Infinite) const
Definition: future_fwd.hpp:587
virtual ~FutureException()
Definition: future_fwd.hpp:117
FutureState wait(int msecs=FutureTimeout_Infinite) const
Definition: future_fwd.hpp:212
bool hasValue(int msecs=FutureTimeout_Infinite) const
Definition: future_fwd.hpp:596
void adaptFuture(const Future< FT > &f, Promise< PT > &p)
Feed a promise from a future of possibly different type.
Definition: future.hxx:621
void futureCancelAdapter(boost::weak_ptr< FutureBaseTyped< FT > > wf)
Definition: future.hxx:578
const std::string & error(int msecs=FutureTimeout_Infinite) const
Definition: future_fwd.hpp:283
Promise< T > & operator=(const Promise< T > &rhs)
Definition: future_fwd.hpp:732
bool isFinished() const
Definition: future_fwd.hpp:239
bool hasValue(int msecs=FutureTimeout_Infinite) const
Definition: future_fwd.hpp:274
const ValueType & value(int msecs=FutureTimeout_Infinite) const
Return the value associated to a Future.
Definition: future_fwd.hpp:200
FutureSync(const FutureSync< T > &b)
Definition: future_fwd.hpp:531
FutureUniqueId uniqueId() const
Definition: future_fwd.hpp:580
Promise(const qi::Promise< T > &rhs)
Definition: future_fwd.hpp:668
FutureUniqueId uniqueId() const
Definition: future_fwd.hpp:174
FutureCallbackType
Definition: future_fwd.hpp:83
void setValue(const ValueType &value)
Definition: future_fwd.hpp:682
FutureSync< T > & operator=(const FutureSync< T > &b)
Definition: future_fwd.hpp:546
Future< T > & operator=(const Future< T > &b)
Definition: future_fwd.hpp:163
boost::chrono::time_point< SteadyClock > time_point
Definition: clock.hpp:45
Future< R > andThenR(FutureCallbackType type, const boost::function< R(const typename Future< T >::ValueType &)> &func)
Definition: future.hxx:121
Future< R > thenR(FutureCallbackType type, const boost::function< R(const Future< T > &)> &func)
Definition: future.hxx:105
Future< R > thenR(const boost::function< R(const Future< T > &)> &func)
Definition: future_fwd.hpp:319
friend void adaptFuture(const Future< FT > &f, Promise< PT > &p)
Feed a promise from a future of possibly different type.
Definition: future.hxx:621
bool hasError(int msecs=FutureTimeout_Infinite) const
Definition: future_fwd.hpp:595
bool isFinished() const
Definition: future_fwd.hpp:593
boost::shared_ptr< detail::FutureBaseTyped< T > > impl()
Definition: future_fwd.hpp:419
void * FutureUniqueId
Definition: future_fwd.hpp:93
FutureState waitUntil(qi::SteadyClock::time_point timepoint) const
Definition: future_fwd.hpp:232
void connectWithStrand(qi::Strand *strand, const boost::function< void(const Future< T > &)> &cb)
Definition: future_fwd.hpp:404
The operation is finished with a value.
Definition: future_fwd.hpp:80
#define QI_GEN(f)
Definition: preproc.hpp:476
Future< T >::Connection Connection
Definition: future_fwd.hpp:521
Future(boost::shared_ptr< detail::FutureBaseTyped< T > > p)
Definition: future_fwd.hpp:420
void adaptFutureUnwrap(Future< AnyReference > &f, Promise< R > &p)
Feed a promise from a generic future which may be unwrapped if it contains itself a future...
Definition: future.hxx:610
bool hasError(int msecs=FutureTimeout_Infinite) const
Definition: future_fwd.hpp:264