Boost logo

Boost :

From: Thorsten Schuett (schuett_at_[hidden])
Date: 2005-10-13 09:33:27


Hi,

I uploaded a new version of the futures library to the boost vault.
http://tinyurl.com/9lws4

Just a remainder, futures execute functions in separate threads. Later the
future can be used to retrieve the result of the function.

The major change is the addition of iterators over futures. Last time some
people complained during the discussion that there were operators missing
which they needed for combining futures. So instead of adding more operators
I added iterators which can be used to implement almost any combination of
futures.

simple_future<int> f1 = bind(fac, 4);
simple_future<int> f1 = bind(fac, 6);
simple_future<int> f1 = bind(fac, 8);

future<int> f = f1 || f2 || f3;

for(future<int>::iterator it = f.begin();
  f.end() != it; ++it){
  cout << *it << endl; // prints fac(4), fac(6) and fac(8)
  if(*it > XXX)
    break;
}

That way, you can wait for as many futures to finish as you want and you can
decide while waiting, for how many you want to wait.

All feedback is appreciated.

Thanks,
Thorsten


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