libqi-api  2.0.6.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Types | Public Member Functions | Protected Attributes | Friends
qi::Future< T > Class Template Reference

#include <future.hpp>

List of all members.

Public Types

typedef FutureType< T >::type ValueType
typedef FutureType< T >::typecast ValueTypeCast
typedef boost::function< void(Future
< T >) > 
Connection

Public Member Functions

 Future ()
 Future (const Future< T > &b)
bool operator== (const Future< T > &other)
Future< T > & operator= (const Future< T > &b)
bool operator< (const Future< T > &b) const
 Future (const ValueType &v, FutureCallbackType async=FutureCallbackType_Async)
const ValueTypevalue (int msecs=FutureTimeout_Infinite) const
 Return the value associated to a Future.
 operator const ValueTypeCast & () const
FutureState wait (int msecs=FutureTimeout_Infinite) const
bool isFinished () const
 isFinished
bool isRunning () const
 isRunning
bool isCanceled () const
 isCanceled
bool hasError (int msecs=FutureTimeout_Infinite) const
 hasError
bool hasValue (int msecs=FutureTimeout_Infinite) const
 hasValue
const std::string & error (int msecs=FutureTimeout_Infinite) const
 error
FutureSync< T > sync ()
void cancel ()
bool isCancelable () const
void connect (const Connection &s)
template<typename FUNCTYPE , typename ARG0 >
void connect (FUNCTYPE fun, ARG0 tracked,...)
void _connect (const boost::function< void()> &s)
boost::shared_ptr
< detail::FutureBaseTyped< T > > 
impl ()
 Future (boost::shared_ptr< detail::FutureBaseTyped< T > > p)

Protected Attributes

boost::shared_ptr
< detail::FutureBaseTyped< T > > 
_p

Friends

class Promise< T >
class FutureSync< T >
template<typename FT , typename PT >
void adaptFuture (const Future< FT > &f, Promise< PT > &p)
template<typename FT , typename PT , typename CONV >
void adaptFuture (const Future< FT > &f, Promise< PT > &p, CONV converter)
 Similar to adaptFuture(f, p) but with a custom converter.

Detailed Description

template<typename T>
class qi::Future< T >

Definition at line 129 of file future.hpp.


Member Typedef Documentation

template<typename T>
typedef boost::function<void (Future<T>) > qi::Future< T >::Connection

Definition at line 262 of file future.hpp.

template<typename T>
typedef FutureType<T>::type qi::Future< T >::ValueType

Definition at line 131 of file future.hpp.

template<typename T>
typedef FutureType<T>::typecast qi::Future< T >::ValueTypeCast

Definition at line 132 of file future.hpp.


Constructor & Destructor Documentation

template<typename T>
qi::Future< T >::Future ( ) [inline]

Definition at line 135 of file future.hpp.

template<typename T>
qi::Future< T >::Future ( const Future< T > &  b) [inline]

Definition at line 140 of file future.hpp.

template<typename T>
qi::Future< T >::Future ( const ValueType v,
FutureCallbackType  async = FutureCallbackType_Async 
) [inline, explicit]

Definition at line 159 of file future.hpp.

template<typename T>
qi::Future< T >::Future ( boost::shared_ptr< detail::FutureBaseTyped< T > >  p) [inline]

Definition at line 293 of file future.hpp.


Member Function Documentation

template<typename T>
void qi::Future< T >::_connect ( const boost::function< void()> &  s) [inline]

Definition at line 290 of file future.hpp.

template<typename T>
void qi::Future< T >::cancel ( ) [inline]

cancel() the asynchronous operation if possible Exact effect is controlled by the cancel implementation, but it is expected to set a value or an error to the Future as fast as possible. Note that cancelation may be asynchronous.

Exceptions:
ExceptionState_FutureNotCancelableif isCancelable() is false.

Definition at line 250 of file future.hpp.

template<typename T>
void qi::Future< T >::connect ( const Connection s) [inline]

Connect a callback function that will be called once when the Future finishes (that is, switches from running to an other state.

Definition at line 267 of file future.hpp.

template<typename T>
template<typename FUNCTYPE , typename ARG0 >
void qi::Future< T >::connect ( FUNCTYPE  fun,
ARG0  tracked,
  ... 
)

Connect a callback with binding and tracking support.

If the first argument is a weak_ptr or a pointer inheriting from qi::Trackable, the callback will not be called if tracked object was destroyed.

template<typename T>
const std::string& qi::Future< T >::error ( int  msecs = FutureTimeout_Infinite) const [inline]

error

Parameters:
msecs
Returns:
the error throw on timeout throw if the future do not have an actual error.

Definition at line 236 of file future.hpp.

template<typename T>
bool qi::Future< T >::hasError ( int  msecs = FutureTimeout_Infinite) const [inline]

hasError

Parameters:
msecstimeout
Returns:
true if the future has an error. throw in the following case:
  • timeout

Definition at line 218 of file future.hpp.

template<typename T>
bool qi::Future< T >::hasValue ( int  msecs = FutureTimeout_Infinite) const [inline]

hasValue

Parameters:
msecstimeout
Returns:
true if the future has a value. throw in the following case:
  • timeout

Definition at line 227 of file future.hpp.

template<typename T>
boost::shared_ptr<detail::FutureBaseTyped<T> > qi::Future< T >::impl ( ) [inline]

Definition at line 292 of file future.hpp.

template<typename T>
bool qi::Future< T >::isCancelable ( ) const [inline]

return true if the future can be canceled. This does not mean that cancel will succeed.

Definition at line 257 of file future.hpp.

template<typename T>
bool qi::Future< T >::isCanceled ( ) const [inline]

isCanceled

Returns:
do not throw

Definition at line 209 of file future.hpp.

template<typename T>
bool qi::Future< T >::isFinished ( ) const [inline]

isFinished

Returns:
true if finished do not throw

Definition at line 195 of file future.hpp.

template<typename T>
bool qi::Future< T >::isRunning ( ) const [inline]

isRunning

Returns:
do not throw

Definition at line 202 of file future.hpp.

template<typename T>
qi::Future< T >::operator const ValueTypeCast & ( ) const [inline]

same as value() with an infinite timeout.

Definition at line 182 of file future.hpp.

template<typename T>
bool qi::Future< T >::operator< ( const Future< T > &  b) const [inline]

Definition at line 155 of file future.hpp.

template<typename T>
Future<T>& qi::Future< T >::operator= ( const Future< T > &  b) [inline]

Definition at line 149 of file future.hpp.

template<typename T>
bool qi::Future< T >::operator== ( const Future< T > &  other) [inline]

Definition at line 144 of file future.hpp.

template<typename T>
FutureSync<T> qi::Future< T >::sync ( ) [inline]

Definition at line 239 of file future.hpp.

template<typename T>
const ValueType& qi::Future< T >::value ( int  msecs = FutureTimeout_Infinite) const [inline]

Return the value associated to a Future.

Parameters:
msecstimeout
Returns:
the value

This function can throw for many reason:

  • wait timeout
  • user error
  • future canceled

if an error is set, then value throw a FutureUserException, others errors are FutureException.

Definition at line 178 of file future.hpp.

template<typename T>
FutureState qi::Future< T >::wait ( int  msecs = FutureTimeout_Infinite) const [inline]

Wait for future to contain a value or an error

Parameters:
msecs,:Maximum time to wait in milliseconds, 0 means return immediately.
Returns:
a FutureState corresponding to the state of the future.

Definition at line 188 of file future.hpp.


Friends And Related Function Documentation

template<typename T>
template<typename FT , typename PT >
void adaptFuture ( const Future< FT > &  f,
Promise< PT > &  p 
) [friend]

Feed a promise from a future of possibly different type. Will monitor f, and bounce its state to p. Error and canceled state are bounced as is. Valued state is bounced through FutureValueConverter<FT, PT>::convert()

Definition at line 314 of file future.hxx.

template<typename T>
template<typename FT , typename PT , typename CONV >
void adaptFuture ( const Future< FT > &  f,
Promise< PT > &  p,
CONV  converter 
) [friend]

Similar to adaptFuture(f, p) but with a custom converter.

Definition at line 324 of file future.hxx.

template<typename T>
friend class FutureSync< T > [friend]

Definition at line 302 of file future.hpp.

template<typename T>
friend class Promise< T > [friend]

Definition at line 301 of file future.hpp.


Member Data Documentation

template<typename T>
boost::shared_ptr< detail::FutureBaseTyped<T> > qi::Future< T >::_p [protected]

Definition at line 300 of file future.hpp.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines