Boost logo

Boost :

From: Thorsten Schuett (schuett_at_[hidden])
Date: 2005-10-17 02:15:20


On Saturday 15 October 2005 15:57, Aristid Breitkreuz wrote:
> Thorsten Schuett <schuett <at> zib.de> writes:
> > 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.
>
> How about limiting the number of threads and queueing, all of course
> configurable in code?
I was thinking about binding a bunch of futures to a thread pool. Thereby you
can control the number of spawned threads and you can reuse the created
threads. But I am not sure whether you can create deadlocks by limiting the
number of concurrently running threads.

Actually you can create deadlocks. Let's say the number of threads in the
following is limited to one. On executing (1) the first thread is spawned.
The spawned thread will try to spawn a second thread in (2). But it has to
wait for the first thread to terminate which will never happen. :-(

int foo(){
  return 0;
}

int bar(){
  future<int> f = int_[foo]; //(2)

  return f();
}

future<int> f = int_[bar]; //(1)
cout << f() << endl;

Thorsten


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