IO::Async::Timer(3pm)

πŸ’– IO::Async::Timer πŸ’–

okay bestie, so IO::Async::Timer is literally the base class for Notifiers that use timed delays. it's giving "mom friend of the timer family" β€” everything else inherits from her ✨

the manual name is IO::Async::Timer(3pm), and she lives in the User Contributed Perl Documentation section, in case you were wondering πŸŽ€


🌸 DESCRIPTION 🌸

so this module gives you a subclass of IO::Async::Notifier for implementing notifiers that use timed delays. it's the blueprint, the blueprint bestie. if you want the actual real ones, go look at one of the subclasses:

  • IO::Async::Timer::Absolute β€” event callback at a fixed future time πŸ‘‘
  • IO::Async::Timer::Countdown β€” event callback after a fixed delay ⏳
  • IO::Async::Timer::Periodic β€” event callback at regular intervals πŸ¦‹

pick your fighter, they're all slaying in their own lane.


🧚 CONSTRUCTOR 🧚

new

$timer = IO::Async::Timer->new( %args );

constructs a particular subclass of IO::Async::Timer object and hands it back to you. no cap.

heads up bestie: this constructor only exists for backward compatibility with older code that doesn't use the subclasses. new code should directly construct a subclass instead. it's giving legacy, it's giving "we keep her around because we love her" πŸ’…
  • mode => STRING β€” the type of timer to create. rn the only allowed mode is "countdown", but more types may be added in the future, so stay tuned fr fr πŸ‘€

once it's constructed, the Timer still needs to be added to the Loop before it'll actually work β€” she needs a home. and she'll also need to be started by the start method, because we don't do anything unprompted around here 😌


✨ METHODS ✨

is_running

$running = $timer->is_running;

returns true if the Timer has been started, and has not yet expired or been stopped. basically "is she still going?" and the answer is a vibe check βœ…

start

$timer->start;

starts the Timer. throws an error if it was already running β€” no double-starting, she's not about that chaotic life 😭

if the Timer is not yet in a Loop, the actual start will be deferred until it is added. once added, it will be running, and will expire at the given duration after the time it was added. the way that timing works is lowkey iconic.

as a convenience, $timer is returned. this may be useful for starting timers at construction time, like this lil chain moment:

$loop->add( IO::Async::Timer->new( ... )->start );

one line, main character energy, obsessed 🫢

stop

$timer->stop;

stops the Timer if it's running. and if it hasn't yet been added to the Loop but there's a start pending, this will cancel it. so she can be stopped before she even gets going β€” that's the power πŸ’€


πŸ‘‘ AUTHOR πŸ‘‘

Paul Evans <leonerd@leonerd.org.uk> β€” the legend herself, we stan πŸ₯°


and that's the whole page bestie, no more notes, periodt πŸ’– this was perl v5.40.1, dated 2026-02-21, and it's the IO::Async::Timer(3pm) page β€” go forth and schedule responsibly 🌈⭐

πŸ“¦ where this page comes from