NAME

Piper::Queue - Simple FIFO queue used by Piper

SYNOPSIS

use Piper::Queue;

my $queue = Piper::Queue->new();
$queue->enqueue(qw(x y));
$queue->ready;         # 2
$queue->dequeue;       # 'x'
$queue->requeue('x');
$queue->dequeue;       # 'x'

CONSTRUCTOR

new

METHODS

dequeue($num)

Remove and return at most $num items from the queue. The default $num is 1.

If $num is greater than the number of items remaining in the queue, only the number remaining will be dequeued.

Returns an array of items if wantarray, otherwise returns the last of the dequeued items, which allows singleton dequeues:

my @results = $queue->dequeue($num);
my $single  = $queue->dequeue;

enqueue(@items)

Add @items to the queue.

ready

Returns the number of elements in the queue.

requeue(@items)

Inserts @items to the top of the queue in an order such that dequeue(1) would subsequently return $items[0] and so forth.

SEE ALSO

Piper::Role::Queue
Piper

VERSION

version 0.02

AUTHOR

Mary Ehlers <ehlers@cpan.org>