Raku Land

Scheduler::DelayBetween

cpan:ATROXAPER

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 atroxaper@cpan.org

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.