in reply to Re^2: Sequential processing with fork.
in thread Sequential processing with fork.
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(); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Sequential processing with fork.
by Anonymous Monk on Aug 06, 2015 at 04:21 UTC | |
by Anonymous Monk on Aug 06, 2015 at 06:43 UTC | |
|
Re^4: Sequential processing with fork.
by Kelicula (Novice) on Aug 08, 2015 at 16:35 UTC | |
by Anonymous Monk on Aug 09, 2015 at 01:49 UTC | |
by Kelicula (Novice) on Jan 29, 2016 at 08:56 UTC | |
by Anonymous Monk on Jan 29, 2016 at 09:39 UTC | |
|
Re^4: Sequential processing with fork.
by Kelicula (Novice) on Aug 09, 2015 at 03:45 UTC | |
by Anonymous Monk on Aug 09, 2015 at 03:53 UTC |