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

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.

gizmo

  • Comment on Re^2: Use Coro for reading EventLog on many pc's?

Replies are listed 'Best First'.
Re^3: Use Coro for reading EventLog on many pc's?
by ikegami (Patriarch) on Mar 14, 2011 at 21:03 UTC

    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;