Help language development. Donate to The Perl Foundation

Scheduler::DelayBetween cpan:ATROXAPER last updated on 2021-01-22

Scheduler-DelayBetween-1.3.2/

Build Status

NAME

Scheduler::DelayBetween - Standard Scheduler's cue sub with the possibility to set a delay between each code execution.

SYNOPSIS

use Scheduler::DelayBetween;

my $cancel = cue({ say 'boom'; sleep 3; }, :5in, :1delay-between);
sleep(5 + (3 + 1) * 13 + 0.7); # got 'boom' 14 times
$cancel.cancel;

DESCRIPTION

Sometimes you may need to execute some code several times with fixed delay between each execution. Standard Scheduler method cue does not provide such possibility. You can achieve it with this module.

It provides a single subroutine:

cue(&code, :$at, :$in, :$every, :$times = 0, :&stop, :&catch, :$delay-between, :$scheduler = $*SCHEDULER --> Cancellation)

Parameters meaning:

The subroutine will return a Cancellation object you can use to cancel the future code runs.

AUTHOR

Mikhail Khorkov [email protected]

Source can be located at: GitHub. Comments and Pull Requests are welcome.

COPYRIGHT AND LICENSE

Copyright 2021 Mikhail Khorkov

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.