GX::Callback::Queue

Module Version: 0.2000_01

NAME

GX::Callback::Queue - Callback queue class

SYNOPSIS

# Load the class
use GX::Callback::Queue;

# Create a new callback queue
$queue = GX::Callback::Queue->new;

# Add a callback
$queue->add( GX::Callback->new( sub { say "Hello!" } ) );

# Process
while ( my $callback = $queue->next ) {
$callback->call;
}

DESCRIPTION

This module provides the GX::Callback::Queue class.

METHODS

Constructor

new

Returns a new GX::Callback::Queue object.

$queue = GX::Callback::Queue->new;
Returns:

Public Methods

add

Adds the given callback objects to the end of the queue.

$queue->add( @callbacks );
Arguments:
Exceptions:

all

Returns all queued callback objects.

@callbacks = $queue->all;
Returns:

Calling this method does not modify the queue.

clear

Clears the queue.

$queue->clear;

clone

Clones the queue.

$cloned_queue = $queue->clone;
Returns:

current

Returns the current callback object (i.e. the one returned by the last next() call).

$callback = $queue->current;
Returns:

next

Removes the next callback object from the queue and returns it.

$callback = $queue->next;
Returns:

remove

Removes the given callback objects from the queue.

$result = $queue->remove( @callbacks );
Arguments:
Returns:
  • $result ( integer )
Exceptions:

remove_all

Removes all remaining callback objects from the queue.

$queue->remove_all;

replace_all

Replaces the remaining callback objects with the given ones.

$queue->replace_all( @callbacks );
Arguments:
Exceptions:

AUTHOR

Jörg A. Uzarek <uzarek@runlevelnull.de>

COPYRIGHT AND LICENSE

Copyright © 2009-2011 Jörg A. Uzarek.

This module is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License Version 3 as published by the Free Software Foundation.