Event::Schedule - A simple way to organize timed events in, say, an IRC bot.
Version 0.01
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.
Creates a new event queue. Notes the time when it does so.
Adds a scheduled event to be run after time seconds. The event is a closure, i.e. a coderef.
Call this every second to run all the closures scheduled for every second between the last tick and the time noe.
Michael Roberts, <michael at vivtek.com>
<michael at vivtek.com>
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.
bug-event-schedule at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Event::Schedule
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Event-Schedule
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Event-Schedule
CPAN Ratings
http://cpanratings.perl.org/d/Event-Schedule
Search CPAN
http://search.cpan.org/dist/Event-Schedule/
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.
To install Event::Schedule, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Event::Schedule
CPAN shell
perl -MCPAN -e shell install Event::Schedule
For more information on module installation, please visit the detailed CPAN module installation guide.