Lunchbox  1.9.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
lunchbox::FutureFunction< T > Class Template Reference

A Future implementation using a boost::function for fulfilment. More...

#include <futureFunction.h>

+ Inheritance diagram for lunchbox::FutureFunction< T >:
+ Collaboration diagram for lunchbox::FutureFunction< T >:

Public Types

typedef boost::function< T() > Func
 The fulfilling function.
 

Public Member Functions

 FutureFunction (const Func &func)
 
- Public Member Functions inherited from lunchbox::FutureImpl< T >
virtual ~FutureImpl ()
 Destruct the future. More...
 
- Public Member Functions inherited from lunchbox::Referenced
void ref (const void *holder LB_UNUSED=0) const
 Increase the reference count. More...
 
bool unref (const void *holder LB_UNUSED=0) const
 Decrease the reference count. More...
 
int32_t getRefCount () const
 
void printHolders (std::ostream &) const
 

Protected Member Functions

wait (const uint32_t) final
 Wait for the promise to be fullfilled. More...
 
bool isReady () const final
 
- Protected Member Functions inherited from lunchbox::Referenced
 Referenced ()
 Construct a new reference-counted object. More...
 
 Referenced (const Referenced &)
 Construct a new copy of a reference-counted object. More...
 
virtual ~Referenced ()
 Destruct a reference-counted object. More...
 
Referencedoperator= (const Referenced &)
 Assign another object to this object. More...
 
virtual LUNCHBOX_API void notifyFree ()
 

Protected Attributes

Func func_
 
result_
 

Detailed Description

template<class T>
class lunchbox::FutureFunction< T >

A Future implementation using a boost::function for fulfilment.

Not thread safe.

Definition at line 38 of file futureFunction.h.

Member Function Documentation

template<class T >
bool lunchbox::FutureFunction< T >::isReady ( ) const
inlinefinalprotectedvirtual
Returns
true if the future has been fulfilled, false if it is pending.

Implements lunchbox::FutureImpl< T >.

Definition at line 58 of file futureFunction.h.

template<class T >
T lunchbox::FutureFunction< T >::wait ( const uint32_t  timeout)
inlinefinalprotectedvirtual

Wait for the promise to be fullfilled.

May be called multiple times.

Parameters
timeoutoptional timeout in milliseconds. If the future is not ready when the timer goes off a timeout exception is thrown.

Implements lunchbox::FutureImpl< T >.

Definition at line 48 of file futureFunction.h.


The documentation for this class was generated from the following file: