Maybe I should go back to implementing my own.
There is no need, nor any point to implementing it as a module.
It takes exactly 5 lines of code:
#! perl -slw use strict; use threads; use Thread::Queue; sub worker { my $Q = shift; my $tid = threads->tid; print "Thread $tid started"; while( defined( my $work = $Q->dequeue ) ) { print "Thread $tid processing workitem $work"; sleep 1; } print "Thread $tid done"; } our $WORKERS //= 10; our $ITEMS //= 30; my $Q = new Thread::Queue; ## 1 my @pool = map threads->new( \&worker, $Q ), 1 .. $WORKERS; ## 2 $Q->enqueue( 1 .. $ITEMS ); ## 3 $Q->enqueue( (undef) x $WORKERS ); ## 4 $_->join for @pool; ## 5 __END__ C:\test>tqpool -WORKERS=3 -ITEMS=10 Thread 1 started Thread 2 started Thread 2 processing workitem 1 Thread 3 started Thread 3 processing workitem 3 Thread 1 processing workitem 2 Thread 2 processing workitem 4 Thread 3 processing workitem 5 Thread 1 processing workitem 6 Thread 2 processing workitem 7 Thread 3 processing workitem 8 Thread 1 processing workitem 9 Thread 2 processing workitem 10 Thread 3 done Thread 1 done Thread 2 done
In reply to Re^7: Why do my threads sometimes die silenty?
by BrowserUk
in thread Why do my threads sometimes die silenty?
by alain_desilets
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |