summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerry D. Hedden <jdhedden@solydxk>2015-10-23 19:55:17 -0400
committerJames E Keenan <jkeenan@cpan.org>2015-10-24 09:41:41 -0400
commit9846bace45546ab19676c8577ccf9218ddd7931d (patch)
tree44d4bb231c0f64c0d159557cdaaeb1b07d4612ae
parent6efa7ebfa4a1063b77411acc0ae8a552dad17c52 (diff)
downloadperl-9846bace45546ab19676c8577ccf9218ddd7931d.tar.gz
Upgrade to Thread::Queue 3.07
Committer: Add additional email address for contributor.
-rwxr-xr-xPorting/Maintainers.pl2
-rwxr-xr-xPorting/checkAUTHORS.pl1
-rw-r--r--dist/Thread-Queue/lib/Thread/Queue.pm28
-rw-r--r--dist/Thread-Queue/t/11_limit.t16
4 files changed, 23 insertions, 24 deletions
diff --git a/Porting/Maintainers.pl b/Porting/Maintainers.pl
index f51a1882e9..97442a5ba1 100755
--- a/Porting/Maintainers.pl
+++ b/Porting/Maintainers.pl
@@ -1153,7 +1153,7 @@ use File::Glob qw(:case);
# correct for this (and Thread::Semaphore, threads, and threads::shared)
# to be under dist/ rather than cpan/
'Thread::Queue' => {
- 'DISTRIBUTION' => 'JDHEDDEN/Thread-Queue-3.06.tar.gz',
+ 'DISTRIBUTION' => 'JDHEDDEN/Thread-Queue-3.07.tar.gz',
'FILES' => q[dist/Thread-Queue],
'EXCLUDED' => [
qr{^examples/},
diff --git a/Porting/checkAUTHORS.pl b/Porting/checkAUTHORS.pl
index 155b8d616e..9b161d253d 100755
--- a/Porting/checkAUTHORS.pl
+++ b/Porting/checkAUTHORS.pl
@@ -663,6 +663,7 @@ jdhedden\100cpan.org jerry\100hedden.us
+ jdhedden\100gmail.com
+ jdhedden\100yahoo.com
+ jhedden\100pn100-02-2-356p.corp.bloomberg.com
++ jdhedden\100solydxk
jeremy\100zawodny.com jzawodn\100wcnet.org
jesse\100sig.bsh.com jesse\100ginger
jfriedl\100yahoo.com jfriedl\100yahoo-inc.com
diff --git a/dist/Thread-Queue/lib/Thread/Queue.pm b/dist/Thread-Queue/lib/Thread/Queue.pm
index b1842ca97b..5a031ff5bd 100644
--- a/dist/Thread-Queue/lib/Thread/Queue.pm
+++ b/dist/Thread-Queue/lib/Thread/Queue.pm
@@ -3,7 +3,7 @@ package Thread::Queue;
use strict;
use warnings;
-our $VERSION = '3.06';
+our $VERSION = '3.07';
$VERSION = eval $VERSION;
use threads::shared 1.21;
@@ -80,7 +80,7 @@ sub dequeue
# Wait for requisite number of items
cond_wait(%$self) while ((@$queue < $count) && ! $$self{'ENDED'});
- cond_signal(%$self) if ((@$queue > $count) || $$self{'ENDED'});
+ cond_signal(%$self) if ((@$queue >= $count) || $$self{'ENDED'});
# If no longer blocking, try getting whatever is left on the queue
return $self->dequeue_nb($count) if ($$self{'ENDED'});
@@ -135,7 +135,7 @@ sub dequeue_timed
while ((@$queue < $count) && ! $$self{'ENDED'}) {
last if (! cond_timedwait(%$self, $timeout));
}
- cond_signal(%$self) if ((@$queue > $count) || $$self{'ENDED'});
+ cond_signal(%$self) if ((@$queue >= $count) || $$self{'ENDED'});
# Get whatever we need off the queue if available
return $self->dequeue_nb($count);
@@ -304,7 +304,7 @@ Thread::Queue - Thread-safe queues
=head1 VERSION
-This document describes Thread::Queue version 3.06
+This document describes Thread::Queue version 3.07
=head1 SYNOPSIS
@@ -488,10 +488,9 @@ C<limit> does not prevent enqueuing items beyond that count:
my $q = Thread::Queue->new(1, 2);
$q->limit = 4;
$q->enqueue(3, 4, 5); # Does not block
- $q->enqueue(6); # Blocks until at least 2 items are
- # dequeued
- my $size = $q->limit; # Returns the current limit (may return
- # 'undef')
+ $q->enqueue(6); # Blocks until at least 2 items are dequeued
+
+ my $size = $q->limit; # Returns the current limit (may return 'undef')
$q->limit = 0; # Queue size is now unlimited
=item ->end()
@@ -515,8 +514,7 @@ while it is being examined and/or changed, L<lock|threads::shared/"lock
VARIABLE"> the queue inside a local block:
{
- lock($q); # Keep other threads from changing the queue's
- # contents
+ lock($q); # Keep other threads from changing the queue's contents
my $item = $q->peek();
if ($item ...) {
...
@@ -595,11 +593,11 @@ of the queue (similar to C<dequeue_nb>) if the count overlaps the head of the
queue from the specified position (i.e. if queue size + index + count is
greater than zero):
- $q->enqueue(qw/foo bar baz/);
- my @nada = $q->extract(-6, 2); # Returns () - (3+(-6)+2) <= 0
- my @some = $q->extract(-6, 4); # Returns (foo) - (3+(-6)+4) > 0
- # Queue now contains: bar, baz
-my @rest = $q->extract(-3, 4); # Returns (bar, baz) - (2+(-3)+4) > 0
+ $q->enqueue(qw/foo bar baz/);
+ my @nada = $q->extract(-6, 2); # Returns () - (3+(-6)+2) <= 0
+ my @some = $q->extract(-6, 4); # Returns (foo) - (3+(-6)+4) > 0
+ # Queue now contains: bar, baz
+ my @rest = $q->extract(-3, 4); # Returns (bar, baz) - (2+(-3)+4) > 0
=back
diff --git a/dist/Thread-Queue/t/11_limit.t b/dist/Thread-Queue/t/11_limit.t
index a2ab91859a..1bd88b39a1 100644
--- a/dist/Thread-Queue/t/11_limit.t
+++ b/dist/Thread-Queue/t/11_limit.t
@@ -44,10 +44,6 @@ my $th = threads->create( sub {
# (6) Get reports from main
my @items = $rpt->dequeue(5);
is_deeply(\@items, [4, 3, 4, 3, 'go'], 'Queue reports');
-
- # Dequeue all items
- @items = $q->dequeue_nb(99);
- is_deeply(\@items, [5, 'foo', 6, 7], 'Queue items');
});
# (2) Read queue limit from thread
@@ -80,16 +76,20 @@ $rpt->enqueue($q->pending);
# Read an item from queue
$item = $q->dequeue();
is($item, 3, 'Dequeued item 3');
-# q = (3, 4, 5); r = (4)
+# q = (4, 5, 'foo'); r = (4, 3, 4)
# Report back the queue count
$rpt->enqueue($q->pending);
# q = (4, 5, 'foo'); r = (4, 3, 4, 3)
-# Read an item from queue
-$item = $q->dequeue();
-is($item, 4, 'Dequeued item 4');
+# Read all items from queue
+my @item = $q->dequeue(3);
+is_deeply(\@item, [4, 5, 'foo'], 'Dequeued 3 items');
# Thread is now unblocked
+@item = $q->dequeue(2);
+is_deeply(\@item, [6, 7], 'Dequeued 2 items');
+
+# Thread is now unblocked
# Handshake with thread
$rpt->enqueue('go');