Boost logo

Boost :

From: Thorsten Schuett (schuett_at_[hidden])
Date: 2005-08-17 07:13:34


On Wednesday 17 August 2005 13:39, Martin Wille wrote:
> Thorsten Schuett wrote:
> > future<int> f3 = f1 || f2;
>
> We'll probably need more than operator ||.
>
> E.g. consider f1 and f2 implement operations that consume time and may
> fail, e.g.:
>
>
> future<whatever> x = query_google_and_check_links_returned ||
> dig_in_local_incomplete_archive;
>
>
> The local archive is faster than searching something over the internet,
> but the search may fail. Having an or-operation that waits for the first
> function to return a *success* would be useful.
Interesting, I never thought of a "failing" future. We could end up with
something like the following:

simple_future<optional<int> > f1;
simple_future<optional<double> > f2;

future<optional<variant<int, double> > > f3 = f1 || f2;

where an empty optional represents failure.

> In another reply, thread-cancellation was mentioned. We don't have
> thread-cancellation currently, but it would be nice if future<> would
> not only accept functors but also allow for an optional interface to be
> passed for signaling an abort request. A user would then be able to
> implement a mechanism that works form her/him. Maybe, an abort policy
> would be the right thing here.
This depends on the cancelation possibilities in boost.thread.

Thorsten


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