18 #ifndef LUNCHBOX_FUTURE_H 19 #define LUNCHBOX_FUTURE_H 21 #include <lunchbox/refPtr.h> 22 #include <lunchbox/referenced.h> 23 #include <boost/noncopyable.hpp> 56 virtual bool isReady()
const = 0;
64 void bool_true()
const {}
70 explicit Future( Impl impl ) : impl_( impl ){}
84 return impl_->wait( timeout_ );
90 bool isReady()
const {
return impl_->isReady(); }
98 bool operator ! () {
return !wait(); }
101 bool operator == (
const T& rhs ) {
return wait() == rhs; }
104 bool operator != (
const T& rhs ) {
return wait() != rhs; }
107 bool operator < (
const T& rhs ) {
return wait() < rhs; }
110 bool operator > (
const T& rhs ) {
return wait() > rhs; }
113 bool operator <= (
const T& rhs ) {
return wait() <= rhs; }
116 bool operator >= (
const T& rhs ) {
return wait() >= rhs; }
130 void bool_true()
const {}
136 explicit Future( Impl impl ) : impl_( impl ){}
150 impl_->wait( timeout_ );
156 bool isReady()
const {
return impl_->isReady(); }
162 #endif //LUNCHBOX_FUTURE_H RefPtr< FutureImpl< void > > Impl
The wait implementation.
~Future()
Destruct the future.
~Future()
Destruct the future.
void wait(const uint32_t timeout_=LB_TIMEOUT_INDEFINITE)
Wait for the promise to be fullfilled.
#define LB_TIMEOUT_INDEFINITE
Constant defining 'wait forever' in methods with wait parameters.
Future template specialization for void.
Future(Impl impl)
Construct a new future.
virtual ~FutureImpl()
Destruct the future.
T wait(const uint32_t timeout_=LB_TIMEOUT_INDEFINITE)
Wait for the promise to be fullfilled.
RefPtr< FutureImpl< T > > Impl
The wait implementation.
Base class to implement the wait method fulfilling the future.
A future represents a asynchronous operation.
Base class for referenced objects.
Future(Impl impl)
Construct a new future.
Abstraction layer and common utilities for multi-threaded programming.
A smart reference pointer, aka boost::intrusive_ptr.
Future< bool > f_bool_t
A boolean future.