Remove array in perl with thread :: queue

I am trying to process data using a set of threads and insert them into a queue by others, currently the process of queuing and deleting the queue does not seem to work

Anyway ???

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

I use the following to put data


my @l;
push(@l, $directories.$suffix);
push(@l, "testclass");
push(@l, $eachFile);
$DataQueue->enqueue(\@l);
+3
source share
2 answers

Can I access an array reference without dereferencing? Try

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

@l is not shared, so you cannot pass a link to another thread. Use thread :: shared.

+1
source

Source: https://habr.com/ru/post/1739045/


All Articles