Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Boolean Thread::Semaphore ?

by Corion (Pope)
on Feb 08, 2012 at 12:04 UTC ( #952468=note: print w/ replies, xml ) Need Help??


in reply to Boolean Thread::Semaphore ?

Why not use a Thread::Queue to distribute the work to your worker threads? The workers will block when the queue is empty and get woken up when there is work to be done.


Comment on Re: Boolean Thread::Semaphore ?
Re^2: Boolean Thread::Semaphore ?
by chrestomanci (Priest) on Feb 08, 2012 at 12:12 UTC

    I am doing that, the work finding thread is putting the work it finds into a Thread::Queue object.

    The reason I want to use a semaphore as well is because the work finder runs much faster than the workers, but is quite expensive in terms of resource consumption.

    If there was not a mechanism to pause the work finder when there is enough work in the queue, it would build a queue of millions of items and waste a lot of memory and other resources in the process.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://952468]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2014-07-29 03:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (211 votes), past polls