From: Benjamin Goldberg Date: Mon, 10 Jun 2002 09:53:42 +0000 (+0000) Subject: queue.pm X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ba95f4f69c1e53f8c3a652a069da9b38d7e4cd57;p=p5sagit%2Fp5-mst-13.2.git queue.pm Message-Id: <3CFC03E8.A1EF9886@earthlink.net> Applied manually p4raw-id: //depot/perl@17160 --- diff --git a/ext/threads/shared/queue.pm b/ext/threads/shared/queue.pm index b5e40a8..30b6ea2 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;