Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^3: Use Coro for reading EventLog on many pc's?

by ikegami (Pope)
on Mar 14, 2011 at 21:03 UTC ( #893161=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Use Coro for reading EventLog on many pc's?
in thread Use Coro for reading EventLog on many pc's?

Thread::Queue is indeed the way to go.

my $q = Thread::Queue->new(); my @threads; for (1..MAX_WORKERS) { push @threads, async { while (my $job = $q->dequeue()) { do_job($job); } }; } # Give work to the workers. for my $job (...) { $q->enqueue($job); } # Signal the workers to exit. $q->enqueue(undef) for 1..MAX_WORKERS; # Wait for the workers to finish. $_->join() for @threads;


Comment on Re^3: Use Coro for reading EventLog on many pc's?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2015-07-04 16:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls