|
Boost : |
Subject: Re: [boost] Futures Review - wait_for_ on fusion sequences
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2009-01-17 09:44:57
Hi,
Could the wait_for_ functions be overloaded for fusion sequences, e.g.
fusion::vector<shared_future<int>, shared_future<string> > seq;
unsigned i = wait_for_any(seq);
I have checkd the followig code and it works for me.
struct waiter_add {
waiter_add(boost::detail::future_waiter& waiter) : waiter_(waiter) {}
boost::detail::future_waiter& waiter_;
template<typename ACT>
void operator()(ACT& act) const {
waiter_.add(act);
}
};
template<typename FusionSequence>
unsigned wait_for_any(FusionSequence& seq) {
boost::detail::future_waiter waiter;
boost::fusion::for_each(seq, waiter_add(waiter));
return waiter.wait();
}
Thanks,
Vicente
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk