summaryrefslogtreecommitdiff
path: root/ext
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
commite9ee1cf673859f742ee0b5177dadb81b4fbdffc9 (patch)
treecd986ad2fa12a702bf682c30ca974731b94995ee /ext
parentc776aef5fd5c268ea004dfccc20a4c12282f719e (diff)
downloadperl-e9ee1cf673859f742ee0b5177dadb81b4fbdffc9.tar.gz
queue.pm
Message-Id: <3CFC03E8.A1EF9886@earthlink.net> Applied manually p4raw-id: //depot/perl@17160
Diffstat (limited to 'ext')
-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;