It's waiting for more stuff to be added to the queue.
If the queue is preloaded and doesn't change, you could use dequeue_nb.
use strict; use warnings; use threads; use threads::shared; use Thread::Queue; my @ary :shared = qw( a b c ); my $q = Thread::Queue->new(); $q->enqueue(\@ary); while (my $ar1 = $q->dequeue_nb()) { print "array reference : $ar1\n@$ar1\n"; }
If data will be added to the queue once the threads have started, use a special value to indicate there is no more data forthcoming. undef would work fine if your queue otherwise contains arrays.
use strict; use warnings; use threads; use threads::shared; use Thread::Queue; my @ary :shared = qw( a b c ); my $q = Thread::Queue->new(); $q->enqueue(\@ary); $q->enqueue(undef); # One for each consumer. while (my $ar1 = $q->dequeue()) { print "array reference : $ar1\n@$ar1\n"; }
In reply to Re: problem in queue implementation
by ikegami
in thread problem in queue implementation
by rajj.nmt4
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |