/usr/share/perl5/Padre/TaskQueue.pm is in padre 1.00+dfsg-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | package Padre::TaskQueue;
# A stripped down and heavily modified version of Thread::Queue,
# more amenable to the needs of Padre.
use 5.008005;
use strict;
use warnings;
use threads;
use threads::shared 1.33;
our $VERSION = '1.00';
our @CARP_NOT = 'threads::shared';
sub new {
my @queue : shared = ();
bless \@queue, $_[0];
}
sub enqueue {
my $self = shift;
lock($self);
push @$self, map { shared_clone($_) } @_;
return cond_signal(@$self);
}
sub pending {
my $self = shift;
lock($self);
return scalar @$self;
}
# Dequeue returns all queue elements, and blocks on an empty queue
sub dequeue {
my $self = shift;
lock($self);
# Wait for there to be anything in the queue
while ( not @$self ) {
cond_wait(@$self);
}
# Return multiple items
my @items = ();
push @items, shift(@$self) while @$self;
return @items;
}
# Pull a single queue element, and block on an empty queue
sub dequeue1 {
my $self = shift;
lock($self);
# Wait for there to be anything in the queue
while ( not @$self ) {
cond_wait(@$self);
}
return shift @$self;
}
# Return items from the head of a queue with no blocking
sub dequeue_nb {
my $self = shift;
lock($self);
# Return multiple items
my @items = ();
push @items, shift @$self while @$self;
return @items;
}
# Return a single item from the head of the queue with no blocking
sub dequeue1_nb {
my $self = shift;
lock($self);
return shift @$self;
}
1;
# Copyright 2008-2013 The Padre development team as listed in Padre.pm.
# LICENSE
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl 5 itself.
|