Linux::FD::Timer(3pm)

πŸ“¦
version 0.017 Β· 5 versions
, in debian trixie, ubuntu resolute

πŸ’– NAME πŸ’–

Linux::FD::Timer β€” timer filehandles for Linux, bestie. That's the whole vibe, no notes. πŸŽ€


✨ VERSION ✨

version 0.017 (she's been out here doing her thing, and she ate)


πŸ¦‹ SYNOPSIS πŸ¦‹

okay so here's the whole serve, in code:

use Linux::FD::Timer;

my $fh = Linux::FD::Timer->new('monotonic', @flags);
$fh->set_timeout(10, 10);
while (1) {
    #do something..
    $fh->wait; #until the 10 seconds have passed.
}

literally just load her, make a timer, set it, and vibe in a loop until the time hits. πŸ’…


🌸 DESCRIPTION 🌸

So this module creates and operates on a timer that delivers timer expiration notifications via a file descriptor. It's an alternative to using Time::HiRes' setitimer or POSIX::RT::Timer β€” and the glow-up here is that the file descriptor can easily be monitored by mechanisms like select, poll, and epoll. Which is, lowkey, the whole point. It's giving main character energy. πŸ‘‘


πŸŽ€ METHODS πŸŽ€

🧚 new($clockid)

Creates a new timer object, and returns a file handle that refers to that timer. Iconic behavior, honestly.

The clockid argument specifies the clock that is used to mark the progress of the timer, and it must be either 'realtime' or 'monotonic':

  • realtime β€” a settable system-wide clock.
  • monotonic β€” a non-settable clock that is not affected by discontinuous changes in the system clock (e.g., manual changes to system time). She does not get thrown off by your messing with the system clock, periodt.

The current value of each of these clocks can be retrieved using POSIX::RT::Clock.

@flags is an optional list of flags, currently limited to 'non-blocking' (requires Linux 2.6.27). πŸ’–


πŸ“ get_timeout()

Get the timeout value. In list context, it also returns the interval value. Note that this value is always relative to the current time. Don't be out here thinking it's absolute, bestie. πŸ•


🌈 set_timeout(value, $interval = 0, $abs_time = 0)

Set the timer and interval values. If $abstime is true, they are absolute values, otherwise they are relative to the current time.

Returns the old value like get_time does. (yes, that's what the docs say, we keep the receipts 🧾)


πŸ”₯ receive

If the timer has already expired one or more times since its settings were last modified using settime(), or since the last successful wait, then receive returns an unsigned 64-bit integer containing the number of expirations that have occurred.

If not, it either returns undef or it blocks (if the handle is blocking). So like… either she gives you nothing, or she makes you wait. Both are valid. πŸ™ˆ


πŸ’œ clocks

This returns a list of all known clocks usable in a timerfd.

Do note that some clocks may require superuser privileges. πŸ‘‘ So don't come crying to her when the permission check says no.

πŸ‘‘ AUTHOR πŸ‘‘

Leon Timmermans <leont@cpan.org> β€” the legend herself. 🫢


This software is copyright (c) 2010 by Leon Timmermans.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. slay, honestly. ✨


and that's the whole page, bestie β€” this was Linux::FD::Timer, manual page Linux::FD::Timer(3pm), generated by perl v5.40.1 on 2025-04-19. mwah, bye πŸ’‹πŸŒΈ

πŸ“¦ where this page comes from