From: Thorsten Schuett (schuett_at_[hidden])
Date: 2005-08-18 01:39:49


On Wednesday 17 August 2005 17:53, Martin Wille wrote:
> Thorsten Schuett wrote:
> > On Wednesday 17 August 2005 16:06, Martin Wille wrote:
> >>I think that would be viable. Another approach would be to pass a
> >>combiner (similar to what Boost.Signals does) and to use
> >>optional<whatever> as return types.
>
> optional<> would be insufficient if we don't have only success/failure
> but some quality indicator. We could return a result if one of the
> futures returns a result with quality == "best". Otherwise, we have to
> wait until all the futures involved have returned a result.
>
> (Something like that would be useful for running several heuristic
> algorithms in parallel with a suitable definition of "best")
How about adding an future-container + an iterator over this container?
Probably we can use the 'or'-future as the container.

simple_future<Result> f1;
...
simple_future<Result> fn;

future<Result> f = f1 || ... || fn;

Result result;
for(future<Result>::iterator it = f.begin(); f.end() != it; ++it){
  if(*it "better than" threshold){
    result = *it;
    //f.cancel() ???
    break;
  }
}

Then you could iterate over the future until your result is good enough. Using
this interface everybody can create his own compositions.

Thorsten