views:

156

answers:

2

I am trying to process data with a set of threads and enqueue it with another, currently the enqueueing and dequeueing process doesn't seem to be working

Any thoughs??

sub process() {
    while (my @DataElement = $DataQueue->dequeue()) {
        print "\t".$DataElement[0]."\n";
    }
}

I use the following to enqueue the data


my @l;
push(@l, $directories.$suffix);
push(@l, "testclass");
push(@l, $eachFile);
$DataQueue->enqueue(\@l);
+4  A: 

Are you accessing an array reference without dereferencing it? Try

while (my $DataElementRef = $DataQueue->dequeue()) {
    my @DataElement = @$DataElementRef;
    print "\t".$DataElement[0]."\n";
}
mobrule
thanks but that doesn't solve the larger issue of not being able to print out anything, There must be something wrong somewhere else
Bob
something in the while statement seems to be wrong and not throwing an error
Bob
A: 

@l is not shared, so you can't pass it's reference to another thread. Use threads::shared.

Telek
Ordinary scalars are added to queues as they are.If not already thread-shared, the other complex data types will be cloned (recursively, if needed, and including any blessings and read-only settings) into thread-shared structures before being placed onto a queue.
gangabass