Piper::Role::Queue - Basic queue role used by the Piper system
The role exists to support future subclassing of Piper (and testing such subclasses) with alternate queueing systems.
This role requires the following object methods.
Removes and returns $num items from the queue.
$num
Default $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):
Ex: my @results = $queue->dequeue($num); my $single = $queue->dequeue;
If requesting more items than are left in the queue, should only return the items left in the queue (and should not return undefs as placeholders).
undef
Adds the @items to the queue. It should not matter what the @items contain, within reason.
@items
Returns the number of items that are ready to be dequeued.
Inserts the @items to the top of the queue in an order such that dequeue(1) would subsequently return $items[0] and so forth.
dequeue(1)
$items[0]
Verify the functionality of a new queue class by downloading the Piper tests and running the following:
PIPER_QUEUE_CLASS=<New queue class> prove t/01_Queue.t
version 0.05
Mary Ehlers <ehlers@cpan.org>
This software is Copyright (c) 2017 by Mary Ehlers.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004
To install Piper, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Piper
CPAN shell
perl -MCPAN -e shell install Piper
For more information on module installation, please visit the detailed CPAN module installation guide.