App::Wubot::Scheduler - schedule events using AnyEvent timers
version 0.5.0
use App::Wubot::Scheduler; my $scheduler = App::Wubot::Scheduler->new(); my $id = 'foo'; # scheduled 'foo' task, runs the method every 5 seconds $scheduler->schedule( $id, sub { print "RUNNING $id!\n" }, 5 ); # reschedule 'foo' to run every 10 seconds. cancels the previous # 5 second timer. $scheduler->reschedule( $id, 10 );
Schedule recurring timers.
Schedule the callback to run after $after seconds, and then run every $interval seconds.
If $interval is not specified, it will default to $after.
The $id is required. The purpose of $id is to give a name to your timer, so that later you can change the schedule using the $id.
Given the $id of a previously scheduled timer, cancel the existing schedule, and schedule the callback to get called next in $after seconds.
Note that the 'interval' will remain unchanged--this will only change the next time the callback gets run.
To install App::Wubot, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::Wubot
CPAN shell
perl -MCPAN -e shell install App::Wubot
For more information on module installation, please visit the detailed CPAN module installation guide.