View on
MetaCPAN
Mary Ehlers > Piper-0.05 > Piper::Role::Queue

Download:
Piper-0.05.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.05   Source  

NAME ^

Piper::Role::Queue - Basic queue role used by the Piper system

DESCRIPTION ^

The role exists to support future subclassing of Piper (and testing such subclasses) with alternate queueing systems.

REQUIRES ^

This role requires the following object methods.

dequeue($num)

Removes and returns $num items from the queue.

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).

enqueue(@items)

Adds the @items to the queue. It should not matter what the @items contain, within reason.

ready

Returns the number of items that are ready to be dequeued.

requeue(@items)

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

TESTING ^

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

SEE ALSO ^

Piper

VERSION ^

version 0.05

AUTHOR ^

Mary Ehlers <ehlers@cpan.org>

COPYRIGHT AND LICENSE ^

This software is Copyright (c) 2017 by Mary Ehlers.

This is free software, licensed under:

  The Apache License, Version 2.0, January 2004
syntax highlighting: