@@ -304,7 +304,7 @@ Thread::Queue - Thread-safe queues
304
304
305
305
=head1 VERSION
306
306
307
- This document describes Thread::Queue version 3.07
307
+ This document describes Thread::Queue version 3.08
308
308
309
309
=head1 SYNOPSIS
310
310
@@ -393,20 +393,20 @@ shared array reference via C<&shared([])>, copy the elements 'foo', 'bar'
393
393
and 'baz' from C<@ary > into it, and then place that shared reference onto
394
394
the queue:
395
395
396
- my @ary = qw/foo bar baz/;
397
- $q->enqueue(\@ary);
396
+ my @ary = qw/foo bar baz/;
397
+ $q->enqueue(\@ary);
398
398
399
399
However, for the following, the items are already shared, so their references
400
400
are added directly to the queue, and no cloning takes place:
401
401
402
- my @ary :shared = qw/foo bar baz/;
403
- $q->enqueue(\@ary);
402
+ my @ary :shared = qw/foo bar baz/;
403
+ $q->enqueue(\@ary);
404
404
405
- my $obj = &shared({});
406
- $$obj{'foo'} = 'bar';
407
- $$obj{'qux'} = 99;
408
- bless($obj, 'My::Class');
409
- $q->enqueue($obj);
405
+ my $obj = &shared({});
406
+ $$obj{'foo'} = 'bar';
407
+ $$obj{'qux'} = 99;
408
+ bless($obj, 'My::Class');
409
+ $q->enqueue($obj);
410
410
411
411
See L</"LIMITATIONS"> for caveats related to passing objects via queues.
412
412
@@ -546,18 +546,18 @@ Adds the list of items to the queue at the specified index position (0
546
546
is the head of the list). Any existing items at and beyond that position are
547
547
pushed back past the newly added items:
548
548
549
- $q->enqueue(1, 2, 3, 4);
550
- $q->insert(1, qw/foo bar/);
551
- # Queue now contains: 1, foo, bar, 2, 3, 4
549
+ $q->enqueue(1, 2, 3, 4);
550
+ $q->insert(1, qw/foo bar/);
551
+ # Queue now contains: 1, foo, bar, 2, 3, 4
552
552
553
553
Specifying an index position greater than the number of items in the queue
554
554
just adds the list to the end.
555
555
556
556
Negative index positions are supported:
557
557
558
- $q->enqueue(1, 2, 3, 4);
559
- $q->insert(-2, qw/foo bar/);
560
- # Queue now contains: 1, 2, foo, bar, 3, 4
558
+ $q->enqueue(1, 2, 3, 4);
559
+ $q->insert(-2, qw/foo bar/);
560
+ # Queue now contains: 1, 2, foo, bar, 3, 4
561
561
562
562
Specifying a negative index position greater than the number of items in the
563
563
queue adds the list to the head of the queue.
@@ -575,18 +575,18 @@ called with no arguments, C<extract> operates the same as C<dequeue_nb>.
575
575
This method is non-blocking, and will return only as many items as are
576
576
available to fulfill the request:
577
577
578
- $q->enqueue(1, 2, 3, 4);
579
- my $item = $q->extract(2) # Returns 3
580
- # Queue now contains: 1, 2, 4
581
- my @items = $q->extract(1, 3) # Returns (2, 4)
582
- # Queue now contains: 1
578
+ $q->enqueue(1, 2, 3, 4);
579
+ my $item = $q->extract(2) # Returns 3
580
+ # Queue now contains: 1, 2, 4
581
+ my @items = $q->extract(1, 3) # Returns (2, 4)
582
+ # Queue now contains: 1
583
583
584
584
Specifying an index position greater than the number of items in the
585
585
queue results in C<undef > or an empty list being returned.
586
586
587
- $q->enqueue('foo');
588
- my $nada = $q->extract(3) # Returns undef
589
- my @nada = $q->extract(1, 3) # Returns ()
587
+ $q->enqueue('foo');
588
+ my $nada = $q->extract(3) # Returns undef
589
+ my @nada = $q->extract(1, 3) # Returns ()
590
590
591
591
Negative index positions are supported. Specifying a negative index position
592
592
greater than the number of items in the queue may return items from the head
@@ -598,8 +598,8 @@ greater than zero):
598
598
my @nada = $q->extract(-6, 2); # Returns () - (3+(-6)+2) <= 0
599
599
my @some = $q->extract(-6, 4); # Returns (foo) - (3+(-6)+4) > 0
600
600
# Queue now contains: bar, baz
601
- my @rest = $q->extract(-3, 4); # Returns
602
- # (bar, baz) - (2+(-3)+4) > 0
601
+ my @rest = $q->extract(-3, 4); # Returns (bar, baz) -
602
+ # (2+(-3)+4) > 0
603
603
604
604
=back
605
605
0 commit comments