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