Boost logo

Boost :

From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2007-03-19 09:55:11


On Friday 16 March 2007 14:24 pm, Braddock Gaskill wrote:
> Yeah, maybe I'll make a seperate "future_friends.hpp" with free
> functions for adding a future callback or a general conversion function.
> That way people can sort of hook into the implementation if they are
> making a broader framework and know what they are doing (like libpoet
> vector adaptors or compositions), but with a clear "do not abuse this at
> home" banner.
>
> I can see many interesting uses of these future adaptor functions, but
> at the end of the day an object that you call to get a return value and
> any arbitrary behavior is called a "functor" not a "future".

I might just drop the constructor with conversionFunction from libpoet's
future class. The same effect can already be achieved with an
active_function, for example extraction from a future vector:

poet::future<std::vector<double> > myVecFuture(/*...*/);
poet::active_function<double (std::vector<double>, unsigned i)>
conversionFunction(boost::bind<const double&>(&std::vector<double>::at,
_1, _2));
poet::future<double> myVecElementFuture = conversionFunction(myVecFuture,
1);

It's a bit overkill to create a new thread just to extract a vector
element, but the user can keep a long-lived scheduler around for use with
trivial active_functions if they care.

-- 
Frank



Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk