News

2009/07/07

Thread::Queue::Action released…

From the docs: A simple class based on Thread::Queue to automatically call subroutines for special queue elements.

Synopsis

use Thread::Queue::Action;

# Create a new queue:
my $q = Thread::Queue::Action -> new ();

# Add an action:
$q -> add_action ('print_items', sub { print join (',', @_), "\n"; });

# Enqueue an item that triggers the action:
$q -> enqueue ({ 'ACTION' => 'print_items', 'PARAMS' => [ 1, 2, 3 ] });

# The sub will be executed on dequeue automatically:
$q -> dequeue (); # prints "1,2,3\n"

# Remove an action:
$q -> remove_action ('print_items');

For more details run ~$ perldoc /path/to/Thread/Queue/Action.pm or - if the module is installed - ~$ perldoc Thread::Queue::Action

Note that the module requires Thread::Queue version 2.11 (or later), which is not available in Debian Lenny, install it via CPAN.

Download

Thread-Queue-Action-0.01.tar.gz (version 0.01, 2009/07/07, 7 kB)

Installation

After downloading, extract the archive, cd to the extracted directory Thread-Queue-Action-0.01/ and run ~/Thread-Queue-Action-0.01$ cpan .

Bugs

Please let me know if any of the tests fail during installation, or if you find any other bugs.

» main » code

Page content licensed under a Creative Commons BY-NC-SA license (deutsche Version).