Quite easy.
use forks; use Thread::Queue qw( ); # 3.01+ use constant NUM_WORKERS => 10; sub work { my ($client) = @_; print("$client start...\n"); sleep(3 + int(rand(2))); print("$client done.\n"); } { my $q = Thread::Queue->new(); for (1..NUM_WORKERS) { async { while (my $client = $q->dequeue()) { work($client); } }; } $q->enqueue($_) for 1..33; $q->end(); $_->join() for forks->list(); }
In reply to Re^3: Sequential processing with fork.
by ikegami
in thread Sequential processing with fork.
by Kelicula
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |