Re: Perlthrtut threadqueue example : possibly incorrect ?
- From: xhoster@xxxxxxxxx
- Date: 28 Nov 2006 16:47:08 GMT
klestes@xxxxxxxxx wrote:
Messing with the example relating to the Thread::Queue, which is :
use threads;
use threads::shared;
use Thread::Queue;
my $DataQueue = new Thread::Queue;
$thr = async {
while ($DataElement = $DataQueue->dequeue) {
They should probably check for definedness, not just for truth,
of the $DataElement.
print "Popped $DataElement off the queue\n";
}
};
$DataQueue->enqueue(12);
$DataQueue->enqueue("A", "B", "C");
$DataQueue->enqueue(\$thr);
sleep 10;
$DataQueue->enqueue(undef);
$thr->join;
And I get an "invalid value for shared scalar". After further messing
around, discovered it works OK if I remove the following line:
$DataQueue->enqueue(\$thr);
So my question is: Wha ?
That is a limitation of Thread::Queue. I don't why they decided to
give an example of this limitation without stating that that is what they
were doing. Thread::Queue::Any should circumvent this problem.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
.
- References:
- Perlthrtut threadqueue example : possibly incorrect ?
- From: klestes
- Perlthrtut threadqueue example : possibly incorrect ?
- Prev by Date: Perlthrtut threadqueue example : possibly incorrect ?
- Next by Date: Re: Errors in Perl Function
- Previous by thread: Perlthrtut threadqueue example : possibly incorrect ?
- Next by thread: Replacement in a string with a function call.
- Index(es):