IO::As...p::Poll(3pm)
π IO::Async::Loop::Poll β the poll(2) era of IO::Async π
okay so bestie, this is a manual page from the Perl world, section 3pm β it's all about IO::Async::Loop::Poll, a subclass of IO::Async::Loop that runs on the poll(2) system call. sit down, grab a strawberry drink π, and let's get into it.
β¨ NAME β¨
IO::Async::Loop::Poll β slaps IO::Async together with poll(2). that's it, that's the whole vibe. π¦
πΈ SYNOPSIS πΈ
ngl, a normal program would not go and construct one of these directly. but likeβ¦ if your program is already out here living its life with an IO::Poll object and you wanna bring IO::Async into the mix? then yeah, this is your moment. π
use IO::Poll;
use IO::Async::Loop::Poll;
my $poll = IO::Poll->new;
my $loop = IO::Async::Loop::Poll->new( poll => $poll );
$loop->add( ... );
while(1) {
my $timeout = ...
my $ret = $poll->poll( $timeout );
$loop->post_poll;
}
that loop is giving main character energy fr fr. π
π DESCRIPTION π
so this class is a subclass of IO::Async::Loop, and it uses the poll(2) system call to do its read-ready and write-ready tests. iconic behavior honestly.
by default, this loop will go straight to the underlying poll() system call itself β bypassing the usual IO::Poll object wrapper that sits around it β and the reason is a whole list of bugs and design flaws in that class. namely:
- <https://rt.cpan.org/Ticket/Display.html?id=93107> β
IO::Pollrelies on stable stringification of IO handles π - <https://rt.cpan.org/Ticket/Display.html?id=25049> β
IO::Poll->poll()with no handles always returns immediately π
and yes, that's two separate tickets, bestie, not me being dramatic. they're both listed for a reason.
but (and here's the good part π«Ά) β if you need to integrate with existing code that's already using an IO::Poll object, you can just call a post_poll right after the poll method on that IO::Poll object. the appropriate mask bits get maintained on the IO::Poll object whenever notifiers are added to or removed from the loop, or whenever they change their want_* status. then the post_poll method inspects the result bits and invokes the on_read_ready or on_write_ready methods on the notifiers. team work makes the dream work. β¨
π CONSTRUCTOR π
π« new
$loop = IO::Async::Loop::Poll->new( %args );
this function returns a brand new instance of an IO::Async::Loop::Poll object. she's fresh out the box. π it takes the following named arguments:
pollβ theIO::Pollobject to use for notification. it's optional; if you don't hand over a value, the underlyingIO::Poll::_poll()function gets invoked directly, outside of the object wrapping. iykyk.
π METHODS π
π§ post_poll
$count = $loop->post_poll;
this method checks the returned event list from an IO::Poll::poll call, and calls any of the notification methods or callbacks that are appropriate. it returns the total number of callbacks that were invoked β that is, the total number of on_read_ready and on_write_ready callbacks for watch_io, plus watch_time event callbacks. she's counting. she's thorough. she ate. π₯
β loop_once
$count = $loop->loop_once( $timeout );
this method calls the poll method on the stored IO::Poll object, passing in the value of $timeout, and then runs the post_poll method on itself. it returns the total number of callbacks invoked by the post_poll method β or undef if the underlying poll method returned an error. π so watch out for that undef, bestie, it's not the vibe you want.
π AUTHOR π
Paul Evans <leonerd@leonerd.org.uk>
absolute legend, we love to see it. π«Ά
and that's the whole page, no notes. this beauty ships with perl v5.40.1, dated 2026-02-21, and it lives in the IO::As...p::Poll(3pm) section of your manual. go forth and poll responsibly πβ¨π
π¦ 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