| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
##################################################################### |
|
2
|
|
|
|
|
|
|
## AUTHOR: Mary Ehlers, regina.verbae@gmail.com |
|
3
|
|
|
|
|
|
|
## ABSTRACT: Basic queue role used by the Piper system |
|
4
|
|
|
|
|
|
|
##################################################################### |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Piper::Role::Queue; |
|
7
|
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
|
8003
|
use v5.10; |
|
|
5
|
|
|
|
|
11
|
|
|
9
|
5
|
|
|
5
|
|
16
|
use strict; |
|
|
5
|
|
|
|
|
9
|
|
|
|
5
|
|
|
|
|
87
|
|
|
10
|
5
|
|
|
5
|
|
17
|
use warnings; |
|
|
5
|
|
|
|
|
9
|
|
|
|
5
|
|
|
|
|
110
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
5
|
|
|
5
|
|
16
|
use Moo::Role; |
|
|
5
|
|
|
|
|
6
|
|
|
|
5
|
|
|
|
|
34
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.03'; # from Piper-0.03.tar.gz |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
|
17
|
|
|
|
|
|
|
#pod |
|
18
|
|
|
|
|
|
|
#pod =for stopwords dequeued queueing |
|
19
|
|
|
|
|
|
|
#pod |
|
20
|
|
|
|
|
|
|
#pod The role exists to support future subclassing of L (and L such subclasses) with alternate queueing systems. |
|
21
|
|
|
|
|
|
|
#pod |
|
22
|
|
|
|
|
|
|
#pod =head1 REQUIRES |
|
23
|
|
|
|
|
|
|
#pod |
|
24
|
|
|
|
|
|
|
#pod This role requires the following object methods. |
|
25
|
|
|
|
|
|
|
#pod |
|
26
|
|
|
|
|
|
|
#pod =head2 dequeue($num) |
|
27
|
|
|
|
|
|
|
#pod |
|
28
|
|
|
|
|
|
|
#pod Removes and returns C<$num> items from the queue. |
|
29
|
|
|
|
|
|
|
#pod |
|
30
|
|
|
|
|
|
|
#pod Default C<$num> should be 1. If wantarray, should return an array of items from the queue. Otherwise, should return the last of the dequeued items (allows singleton dequeues, behaving similar to splice): |
|
31
|
|
|
|
|
|
|
#pod |
|
32
|
|
|
|
|
|
|
#pod Ex: |
|
33
|
|
|
|
|
|
|
#pod my @results = $queue->dequeue($num); |
|
34
|
|
|
|
|
|
|
#pod my $single = $queue->dequeue; |
|
35
|
|
|
|
|
|
|
#pod |
|
36
|
|
|
|
|
|
|
#pod If requesting more items than are left in the queue, should only return the items left in the queue (and should not return Cs as placeholders). |
|
37
|
|
|
|
|
|
|
#pod |
|
38
|
|
|
|
|
|
|
#pod =cut |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
requires 'dequeue'; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
#pod =head2 enqueue(@items) |
|
43
|
|
|
|
|
|
|
#pod |
|
44
|
|
|
|
|
|
|
#pod Adds the C<@items> to the queue. It should not matter what the C<@items> contain, within reason. |
|
45
|
|
|
|
|
|
|
#pod |
|
46
|
|
|
|
|
|
|
#pod =cut |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
requires 'enqueue'; |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
#pod =head2 ready |
|
51
|
|
|
|
|
|
|
#pod |
|
52
|
|
|
|
|
|
|
#pod Returns the number of items that are ready to be dequeued. |
|
53
|
|
|
|
|
|
|
#pod |
|
54
|
|
|
|
|
|
|
#pod =cut |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
requires 'ready'; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
#pod =head2 requeue(@items) |
|
59
|
|
|
|
|
|
|
#pod |
|
60
|
|
|
|
|
|
|
#pod Inserts the C<@items> to the top of the queue in an order such that C would subsequently return C<$items[0]> and so forth. |
|
61
|
|
|
|
|
|
|
#pod |
|
62
|
|
|
|
|
|
|
#pod =cut |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
requires 'requeue'; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
#pod =head1 TESTING |
|
67
|
|
|
|
|
|
|
#pod |
|
68
|
|
|
|
|
|
|
#pod Verify the functionality of a new queue class by downloading the L tests and running the following: |
|
69
|
|
|
|
|
|
|
#pod |
|
70
|
|
|
|
|
|
|
#pod PIPER_QUEUE_CLASS= prove t/01_Queue.t |
|
71
|
|
|
|
|
|
|
#pod |
|
72
|
|
|
|
|
|
|
#pod =cut |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__END__ |