
Is there any fantastically good reason why there is no way of getting a count of how many threads are being handled by a thread_group? I want to set up a worker thread pool, a new thread is added as the queue size goes up, and it removed itself if the queue size is not enough to warrant it. This mechanism, however, is complicated muchly when thread_group doesn't have a way for me to determine how many threads I currently have, in an effort to ensure the ending the thread will cause it to go below the minimum, or spawning a new one go above the maximum. Obviously, I could write my own thread_group, but I can think of no reason for boost's thread_group to not have a count() method. -- PreZ :) Founder. The Neuromancy Society (http://www.neuromancy.net)

Preston A. Elder wrote:
Is there any fantastically good reason why there is no way of getting a count of how many threads are being handled by a thread_group?
I want to set up a worker thread pool, a new thread is added as the queue size goes up, and it removed itself if the queue size is not enough to warrant it. This mechanism, however, is complicated muchly when thread_group doesn't have a way for me to determine how many threads I currently have, in an effort to ensure the ending the thread will cause it to go below the minimum, or spawning a new one go above the maximum.
Obviously, I could write my own thread_group, but I can think of no reason for boost's thread_group to not have a count() method.
I don't see one either. I'll look into adding one. Mike

Michael Glassford <glassfordm@hotmail.com> wrote: Preston A. Elder wrote:
Is there any fantastically good reason why there is no way of getting a count of how many threads are being handled by a thread_group?
<snip>
Obviously, I could write my own thread_group, but I can think of no reason for boost's thread_group to not have a count() method.
I don't see one either. I'll look into adding one.
Keeping the count correct in the face of exceptions or other cancellations may have some consequences... matt.

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)
participants (3)
-
Matt Hurd
-
Michael Glassford
-
Preston A. Elder