Keep It Simple, Stupid | |
PerlMonks |
Re^4: How to create thread pool of ithreadsby BrowserUk (Patriarch) |
on Jan 14, 2009 at 17:30 UTC ( [id://736295]=note: print w/replies, xml ) | Need Help?? |
Is the AnonymousMonk above also you? The threads will automatically go into a wait state when there is nothing in the queue. And as soon as you add something new to the queue, one of them will wake up to deal with it. That's the beauty of the architecture. Now, assuming you're the AnonyMonk from above, the way to deal with the situation of the queue growing when you have large volumes of work items available very quickly, is to slightly restructure the code above to start the threads first, and then feed the work items into the queue in batches, and sleeping between batches to give the workers time to deal with them. There are several arrangements for doing this and the best choice will depend upon other details of your application. If you confirm that you are the anonymonk and this is the problem you are encountering, and you are prepared to divulge a little further information about your application, then I'll try to suggest an applicable arrangement. Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
In Section
Seekers of Perl Wisdom
|
|