Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2007-03-14 16:48:31


Braddock Gaskill wrote:

> So, that would mean that for f3 = f1 || f2, if f1 propagates an
> exception while f2 succeeds, f3 still propagates an exception?

I think that one sensible meaning of f1 || f2 is to wait until either one of
f1 or f2 returns a value, or both fail.

The "first to complete" approach is supported by my proposed future<>, but
not in a composable way. You can hand the same future<> to two producers and
the first one to place a value or an exception into it wins. But I haven't
investigated the infrastructure that would allow operator||.

As for operator&&, it doesn't deliver any extra functionality. Instead of
wating for f1 && f2, you just wait for f1, then f2:

future<int> f1 = fork( f, x );
future<int> f2 = fork( f, y );

std::cout << f1 + f2 << std::endl;

There's no need to do:

future< pair<int, int> > f3 = f1 && f2;
pair<int,int> p = f3;
std::cout << p.first + p.second << std::endl;


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