The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Event::Schedule - A simple way to organize timed events in, say, an IRC bot.

VERSION

Version 0.01

SYNOPSIS

This class implements a very simple event schedule to be used in-process for simple functionality. It was developed in the context of an IRC bot to enforce Roberts Rules of Order on a channel; when someone is given the floor for a minute, we can simply schedule a call to a warning function in 60 seconds. We set a timer to call the event queue every second.

Obviously, long-running functions should not be called here. Use threads for that.

The event itself is a closure, or anonymous coderef. This makes it easy to encapsulate a given call with its parameters. If you've never encountered closures before, then this is your lucky day.

    use Event::Schedule;

    my $queue = Event::Schedule->new();

    # Let's schedule an event for a minute from now.
    $queue->add (60, sub { my_function ($a, $b); });

    ...  (we wait 60 seconds) ...
    $queue->tick(); # My function executes.

Future functionality could include a queue lister and perhaps some callback way to remove obsolete events from the queue.

FUNCTIONS

new()

Creates a new event queue. Notes the time when it does so.

add($time, $event)

Adds a scheduled event to be run after time seconds. The event is a closure, i.e. a coderef.

tick()

Call this every second to run all the closures scheduled for every second between the last tick and the time noe.

AUTHOR

Michael Roberts, <michael at vivtek.com>

BUGS

Please report any bugs or feature requests to bug-event-schedule at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Event-Schedule. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Event::Schedule

You can also look for information at:

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

Copyright 2010 Michael Roberts, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.