summaryrefslogtreecommitdiff
path: root/ext/threads
diff options
context:
space:
mode:
authorBenjamin Goldberg <goldbb2@earthlink.net>2002-06-10 09:53:42 +0000
committerArtur Bergman <sky@nanisky.com>2002-06-10 09:53:42 +0000
commitba95f4f69c1e53f8c3a652a069da9b38d7e4cd57 (patch)
treecd986ad2fa12a702bf682c30ca974731b94995ee /ext/threads
parent9c20e9bc2196ed149d3bedb9d3f98c0431f1b990 (diff)
downloadperl-ba95f4f69c1e53f8c3a652a069da9b38d7e4cd57.tar.gz
queue.pm
Message-Id: <3CFC03E8.A1EF9886@earthlink.net> Applied manually p4raw-id: //depot/perl@17160
Diffstat (limited to 'ext/threads')
-rw-r--r--ext/threads/shared/queue.pm21
1 files changed, 8 insertions, 13 deletions
diff --git a/ext/threads/shared/queue.pm b/ext/threads/shared/queue.pm
index b5e40a838e..30b6ea29ec 100644
--- a/ext/threads/shared/queue.pm
+++ b/ext/threads/shared/queue.pm
@@ -74,32 +74,27 @@ sub new {
sub dequeue {
my $q = shift;
lock(@$q);
- until(@$q) {
- cond_wait(@$q);
- }
+ cond_wait @$q until @$q;
+ cond_signal @$q if @$q > 1;
return shift @$q;
}
sub dequeue_nb {
- my $q = shift;
- lock(@$q);
- if (@$q) {
+ my $q = shift;
+ lock(@$q);
return shift @$q;
- } else {
- return undef;
- }
}
sub enqueue {
my $q = shift;
lock(@$q);
- push(@$q, @_) and cond_broadcast @$q;
+ push @$q, @_ and cond_signal @$q;
}
sub pending {
- my $q = shift;
- lock(@$q);
- return scalar(@$q);
+ my $q = shift;
+ lock(@$q);
+ return scalar(@$q);
}
1;