NAME

App::Wubot::Scheduler - schedule events using AnyEvent timers

VERSION

version 0.5.0

SYNOPSIS

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
                      );

DESCRIPTION

Schedule recurring timers.

SUBROUTINES/METHODS

$obj->schedule( $id, $callback, $after, $interval )

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.

$obj->reschedule( $id, $after )

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.