7 #ifndef QI_DETAIL_FUTURE_BARRIER_HXX_
8 #define QI_DETAIL_FUTURE_BARRIER_HXX_
30 this->
_promise.setValue(this->_futures);
168 :
_p(boost::make_shared<detail::FutureBarrierPrivate<T> >(
async))
171 boost::function<
void()>(),
190 if (
_p->_closed.load())
191 throw std::runtime_error(
"Adding future to closed barrier");
195 _p->_futures.push_back(fut);
211 return _p->_promise.future();
215 boost::shared_ptr<detail::FutureBarrierPrivate<T> >
_p;
220 if (
_p->_count.load() == 0) {
221 if (!
_p->_set.swap(
true))
222 _p->_promise.setValue(
_p->_futures);
236 template <
typename T>
238 typename std::vector< Future<T> >::iterator it;
241 for (it = vect.begin(); it != vect.end(); ++it) {
258 template <
typename T>
260 typename std::vector< Future<T> >::iterator it;
263 count->
swap((
int)vect.size());
264 for (it = vect.begin(); it != vect.end(); ++it) {
265 it->connect(boost::bind<void>(&detail::waitForFirstHelper<T>, prom, *it, count));
FutureBarrier(FutureCallbackType async=FutureCallbackType_Async)
FutureBarrier constructor taking no argument.
void connect(const AF &fun, FutureCallbackType type=FutureCallbackType_Auto)
void PromiseNoop(qi::Promise< T > &)
Helper function that does nothing on future cancelation.
void addFuture(qi::Future< T > fut)
Adds the future to the barrier.
This class helps waiting on multiple futures at the same point.
std::enable_if< std::is_function< RF >::value, boost::function< RF > >::type bindWithFallback(boost::function< void()> onFail, AF &&fun, Arg0 &&arg0, Args &&...args)
#define QI_ASSERT(expr__)
Future< std::vector< Future< T > > > future()
Gets the future result for the barrier.
qi::FutureSync< std::vector< Future< T > > > waitForAll(std::vector< Future< T > > &vect)
Helper function to wait on a vector of futures.
std::vector< Future< T > > _futures
Future< T > future() const
Get a future linked to this promise. Can be called multiple times.
Future< R > async(boost::function< R()> callback, uint64_t usDelay)
Promise< std::vector< Future< T > > > _promise
FutureBarrierPrivate(FutureCallbackType async=FutureCallbackType_Async)
FutureBarrier constructor taking no argument.
boost::shared_ptr< detail::FutureBarrierPrivate< T > > _p
qi::FutureSync< qi::Future< T > > waitForFirst(std::vector< Future< T > > &vect)
Helper function to wait for the first valid future.