AnyEvent-DateTime-Cron
view release on metacpan or search on metacpan
Returns a hashref containing all the current cron jobs.
debug()
$cron->debug(1|0)
Turn on debugging.
CALLBACKS
A callback is a coderef (eg an anonymous subroutine) which will be
called every time your job is triggered. Callbacks should use "AnyEvent"
themselves, so that they run asynchronously, otherwise they can block
the execution of the cron loop, delaying other jobs.
Two parameters are passed to your callback: the main $cv of the cron
loop, and the $job_description which contains various details about the
current job.
The $cv is the most important parameter, as it allows you to control how
your cron loop will shut down. If your callback doesn't use "AnyEvent"
and is blocking, then your callback will complete before it returns to
the cron loop.
However, if your callback is running asynchronously (and it really
should), then you can block the cron loop from responding to a "stop()"
request until your job has completed:
sub {
my $cv = shift;
$cv->begin;
do_something_asynchronous( cb => sub { $cv->end })
}
Callbacks are called inside an "eval" so if they throw an error, they
will warn, but won't cause the cron loop to exit.
AUTHORS
* Clinton Gormley <drtech@cpan.org>
* Andy Gorman <agorman@cpan.org>
lib/AnyEvent/DateTime/Cron.pm view on Meta::CPAN
=head2 debug()
$cron->debug(1|0)
Turn on debugging.
=head1 CALLBACKS
A callback is a coderef (eg an anonymous subroutine) which will be called
every time your job is triggered. Callbacks should use C<AnyEvent> themselves,
so that they run asynchronously, otherwise they can block the execution
of the cron loop, delaying other jobs.
Two parameters are passed to your callback: the main C<$cv> of the cron loop,
and the C<$job_description> which contains various details about the current
job.
The C<$cv> is the most important parameter, as it allows you to control how
your cron loop will shut down. If your callback doesn't use
C<AnyEvent> and is blocking, then your callback will complete before it
returns to the cron loop.
However, if your callback is running asynchronously (and it really should),
then you can block the cron loop from responding to a L</"stop()"> request
until your job has completed:
sub {
my $cv = shift;
$cv->begin;
do_something_asynchronous( cb => sub { $cv->end })
}
Callbacks are called inside an C<eval> so if they throw an error, they
will warn, but won't cause the cron loop to exit.
=head1 AUTHORS
=over 4
=item *
( run in 0.957 second using v1.01-cache-2.11-cpan-0d8aa00de5b )