Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

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

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

in reply to Use Coro for reading EventLog on many pc's?

Coro offers a cooperative multitasking solution, and your calls to process_pc aren't cooperating (so to speak). Get rid of the call to cede (which would be useless in a functioning Coro version anyway) and switch use Coro; to use threads;.

Note that both Coro's and threads's async functions return an object (not some id).

Replies are listed 'Best First'.
Re^2: Use Coro for reading EventLog on many pc's?
by gizmo_mathboy (Friar) on Mar 14, 2011 at 20:59 UTC

    Thank you much. That helped speed things up.

    Now to re-read the docs for threads to figure out how to limit the number of threads I have so I don't saturate my network connection. I initially was looking at Thread:Queue but I wasn't understanding it properly. Maybe with this bit of helpful knowledge I can grok the docs.


      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;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://893155]
[MidLifeXis]: corelist Typo. Wow. Time to go, fingers are malfunctioning.
[marioroy]: Thanks MidLifeXis. Leaned another thing about Perl. Wow.
[marioroy]: Didn't know of corelist until today. Cool.
[marioroy]: Lady_Aleena Which module?

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (11)
As of 2017-05-24 18:01 GMT
Find Nodes?
    Voting Booth?