18 #ifndef LUNCHBOX_REQUEST_H 19 #define LUNCHBOX_REQUEST_H 21 #include <boost/mpl/if.hpp> 22 #include <boost/type_traits/is_same.hpp> 23 #include <lunchbox/future.h> 31 : std::runtime_error(
"wait on an unregistered request")
56 uint32_t getID()
const;
71 #include <lunchbox/requestHandler.h> 77 typedef typename boost::mpl::if_<boost::is_same<T, void>,
void*, T>::type
89 const uint32_t request;
94 if (state_ == UNRESOLVED)
96 state_ = UNREGISTERED;
97 handler_.unregisterRequest(request);
101 bool isUnresolved()
const {
return state_ == UNRESOLVED; }
104 T
wait(
const uint32_t timeout)
final 111 if (!handler_.waitRequest(request, result, timeout))
127 return handler_.isRequestReady(request);
154 if (!handler_.waitRequest(request, result, timeout))
171 if (static_cast<const Impl*>(this->impl_.get())->isUnresolved())
178 return static_cast<const Impl*
>(this->impl_.get())->request;
188 #endif // LUNCHBOX_REQUEST_H bool isReady() const final
virtual ~Request()
Destruct and wait for completion of the request, unless relinquished.
Request(RequestHandler &handler, const uint32_t request)
Construct a new request.
T wait(const uint32_t timeout_=LB_TIMEOUT_INDEFINITE)
Wait for the promise to be fullfilled.
A Future implementation for a RequestHandler request.
void unregister()
Unregister this request from the request handler.
Base class to implement the wait method fulfilling the future.
A future represents a asynchronous operation.
Abstraction layer and common utilities for multi-threaded programming.
A thread-safe request handler.
T wait(const uint32_t timeout) final
Wait for the promise to be fullfilled.