Boost logo

Boost :

From: Preston A. Elder (prez_at_[hidden])
Date: 2005-02-10 18:56:46


On Thu, 10 Feb 2005 06:52:51 -0500, Michael Glassford wrote:

Supplementary question, though not necessarily related.

What happens if the function that a thread in a thread pool is executing
ends?

Assuming you did:

thread_pool tp;

tp.create(&some_func);
tp.create(&some_func);
tp.create(&some_func);

Now, lets say one of the functions ends, however the other two are still
going, and likely to remain so, will the thread's context be cleaned up?
or will it be a leak until that thread pool is destroyed?

One of the properties of a dynamic thread pool is that threads are added
and removed as necessary (usually due to work load). This means I may go
back to 2 threads after one of the first 3 dies, but later on, I might
need 3 again, so I'll create a new one. One of these threads will again
die later once the work load goes down.

Its sounding like thread_pool is only really a useful device for a
statically sized or always-growing thread pool.

-- 
PreZ :)
Founder. The Neuromancy Society (http://www.neuromancy.net)

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