18 #ifndef LUNCHBOX_REQUEST_H
19 #define LUNCHBOX_REQUEST_H
21 #include <lunchbox/future.h>
22 #include <boost/mpl/if.hpp>
23 #include <boost/type_traits/is_same.hpp>
47 uint32_t
getID()
const;
63 #include <lunchbox/requestHandler.h>
69 boost::mpl::if_< boost::is_same< T, void >,
void*, T >::type value_t;
77 , relinquished_(
false )
81 const uint32_t request;
85 bool isRelinquished()
const {
return relinquished_; }
88 T
wait(
const uint32_t timeout )
final
95 if ( !handler_.waitRequest( request, result, timeout ))
104 return done_ || ( !relinquished_ && handler_.isRequestReady( request ));
120 if ( !handler_.
waitRequest( request, result, timeout ))
126 template<
class T >
inline
133 if( !static_cast< const Impl* >( this->impl_.get( ))->isRelinquished( ))
139 return static_cast< const Impl*
>( this->impl_.get( ))->request;
144 static_cast< Impl*
>( this->impl_.get( ))->relinquish();
149 #endif //LUNCHBOX_REQUEST_H
virtual ~Request()
Destruct and wait for completion of the request, unless relinquished.
Request(RequestHandler &handler, const uint32_t request)
Construct a new request.
LUNCHBOX_API bool waitRequest(const uint32_t requestID, void *&result, const uint32_t timeout=LB_TIMEOUT_INDEFINITE)
Wait a given time for the completion of a request.
void relinquish()
Abandon the request.
A Future implementation for a RequestHandler request.
RefPtr< FutureImpl< T > > Impl
The wait implementation.
Base class to implement the wait method fulfilling the future.
bool isReady() const final
A future represents a asynchronous operation.
A thread-safe request handler.
T wait(const uint32_t timeout) final
Wait for the promise to be fullfilled.