IO::As...solute(3pm)

πŸ’– IO::Async::Timer::Absolute β€” the group chat manual page πŸ’–

okay so bestie, this is IO::Async::Timer::Absolute, straight out of the User Contributed Perl Documentation crew. It's giving "wake me up at exactly this moment" energy, and honestly? Iconic. πŸ‘‘


✨ NAME ✨

IO::Async::Timer::Absolute β€” event callback at a fixed future time πŸ•°οΈ


🌸 SYNOPSIS 🌸

Bestie, here's the whole vibe, verbatim, no cap:

use IO::Async::Timer::Absolute;

use POSIX qw( mktime );

use IO::Async::Loop;
my $loop = IO::Async::Loop->new;

my @time = gmtime;

my $timer = IO::Async::Timer::Absolute->new(
   time => mktime( 0, 0, 0, $time[3]+1, $time[4], $time[5] ),

   on_expire => sub {
      print "It's midnight\n";
      $loop->stop;
   },
);

$loop->add( $timer );

$loop->run;

πŸ¦‹ DESCRIPTION πŸ¦‹

So this is a subclass of IO::Async::Timer, and what it does is one-shot events at a fixed time in the future. The object literally just sits there waiting for a given timestamp, and then β€” boom πŸ’₯ β€” it invokes its callback at that point in the future. No cap, that's the whole personality.

But listen, if you want a Timer object that waits for a delay relative to the time it is started instead? That's a whole different bestie. Go see IO::Async::Timer::Countdown instead. 🫢


πŸ”₯ EVENTS πŸ”₯

The following events are invoked, either using subclass methods or CODE references in parameters:

πŸ’… on_expire

Invoked when the timer expires. That's it, that's the moment. ✨


πŸŽ€ PARAMETERS πŸŽ€

The following named parameters may be passed to new or configure:

πŸ“ on_expire => CODE

CODE reference for the on_expire event. Give it a sub and it'll call it when the clock hits. πŸ•

⭐ time => NUM

The epoch time at which the timer will expire. Mark the calendar, bestie. πŸ“…

Once constructed, the timer object will need to be added to the Loop before it will work. Don't forget that step, seriously, it will simply not do anything otherwise. πŸ™ˆ

Unlike other timers, it does not make sense to start this object, because its expiry time is absolute, and not relative to the time it is started. Like, it already knows when it's going down. Starting it is just… not the move. πŸ’€


πŸ‘‘ AUTHOR πŸ‘‘

Paul Evans <leonerd@leonerd.org.uk> β€” the main character who wrote this, periodt. 🌈


friendly reminder: absolute time means absolute. Don't @ me, don't start it, just add it to the loop and let it cook.

And that's the page, bestie!! This little beauty shipped as perl v5.40.1, dated 2026-02-21 β€” and I fear that is simply the slayest documentation date I've ever seen. Mwah. πŸ’‹πŸ§š

πŸ“¦ where this page comes from