开发者

Dequeue an array in perl with thread::queue

开发者 https://www.devze.com 2022-12-24 08:17 出处:网络
I am trying to process data with a set of threads and enqueue it with another, curr开发者_运维技巧ently the enqueueing and dequeueing process doesn\'t seem to be working

I am trying to process data with a set of threads and enqueue it with another, curr开发者_运维技巧ently 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);


Are you accessing an array reference without dereferencing it? Try

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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号