IO::As...riodic(3pm)
β¨ IO::Async::Timer::Periodic(3pm) β aka the group chat's fave recurring bestie β¨
okay so this is a page from the User Contributed Perl Documentation, and it's all about "IO::Async::Timer::Periodic" π
πΈ NAME πΈ
"IO::Async::Timer::Periodic" β event callback at regular intervals π
periodt, that's the whole vibe.
π SYNOPSIS π
bestie here's the whole thing, copy-paste ready, i'm not even kidding:
use IO::Async::Timer::Periodic;
use IO::Async::Loop;
my $loop = IO::Async::Loop->new;
my $timer = IO::Async::Timer::Periodic->new(
interval => 60,
on_tick => sub {
print "You've had a minute\n";
},
);
$timer->start;
$loop->add( $timer );
$loop->run;
like. she's beauty, she's grace, she prints every sixty seconds. π¦
π DESCRIPTION π
so this is a subclass of IO::Async::Timer, right, and what she does is implement repeating events at regular clock intervals. iconic behaviour honestly.
and here's the tea: the timing may or may not be subject to how long it takes the callback to execute. π like, that's a real thing that depends on stuff. the iterations can be rescheduled as runs at fixed regular intervals, beginning at the time the timer was started β or by a fixed delay after the previous code has finished executing. your call, bestie.
if you want a "Timer" object that only runs a callback once, after a given delay? that's a different girl. go see IO::Async::Timer::Countdown instead π. a Countdown timer can also be used to create repeating events that fire at a fixed delay after the previous event has finished processing. see also the examples in "IO::Async::Timer::Countdown" for that π«Ά
π₯ EVENTS π₯
the following events get invoked, either using subclass methods or CODE references in parameters:
on_tick
invoked on each interval of the timer. that's it. that's her job. π
π PARAMETERS π
these named parameters can be passed to "new" or "configure":
on_tick => CODE
CODE reference for the "on_tick" event. feed her a sub and she'll call it. π
interval => NUM
the interval in seconds between invocations of the callback or method.
β οΈ okay so listen: this one cannot be changed if the timer is running. no cap. pick your number and live with it, or stop the timer first. π
first_interval => NUM
optional β¨ if defined, this is the interval in seconds after calling the "start" method before the first invocation of the callback or method. thereafter, the regular "interval" will be used. if you don't supply it, the first interval will be the same as the others. simple as. π
even if this value is zero, the first invocation will be made asynchronously, by the containing "Loop" object β and not synchronously by the "start" method itself. so don't come for start when nothing fires instantly, it's not her fault, it's giving asynchronous main character energy π
reschedule => STRING
optional β¨ must be one of "hard", "skip" or "drift". this defines the algorithm used to reschedule the next invocation. three girls, three strategies, let's go:
"hard"β schedules each iteration at the fixed interval from the previous iteration's schedule time, ensuring a regular repeating event. she's predictable, she's punctual, she's an icon. π"skip"β schedules similarly to"hard", but skips over times that have already passed. this matters if the duration is particularly short and there's a possibility that times may be missed, or if the entire process is stopped and resumed by"SIGSTOP"or similar. π΄β‘οΈπ"drift"β schedules each iteration at the fixed interval from the time that the previous iteration's event handler returns. this allows it to slowly drift over time and become desynchronised with other events of the same interval or multiples/fractions of it. she's on her own schedule fr fr π¦
π¨ one more thing before you go, bestie!! once constructed, the timer object will need to be added to the"Loop"before it will work. it will also need to be started by the"start"method. don't forget either step or she'll just sit there looking pretty with zero vibes happening. π
β AUTHOR β
Paul Evans <leonerd@leonerd.org.uk> β thank u king π
and that's the whole page!! you ate that π this was perl v5.40.1, dated 2026-02-21, and yes the manual name is IO::As...riodic(3pm) because the header got squished but we all know who she is π bye bestie!! πΈπ¦β¨
π¦ where this page comes from
- ubuntu stonking: libio-async-perl 0.805-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms