.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "IO::Async::Loop::Poll 3pm" .TH IO::Async::Loop::Poll 3pm 2024-02-04 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME "IO::Async::Loop::Poll" \- use "IO::Async" with "poll(2)" .SH SYNOPSIS .IX Header "SYNOPSIS" Normally an instance of this class would not be directly constructed by a program. It may however, be useful for runinng IO::Async with an existing program already using an \f(CW\*(C`IO::Poll\*(C'\fR object. .PP .Vb 2 \& 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; \& } .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" This subclass of IO::Async::Loop uses the \f(CWpoll(2)\fR system call to perform read-ready and write-ready tests. .PP By default, this loop will use the underlying \f(CWpoll()\fR system call directly, bypassing the usual IO::Poll object wrapper around it because of a number of bugs and design flaws in that class; namely .IP \(bu 2 \- IO::Poll relies on stable stringification of IO handles .IP \(bu 2 \- IO::Poll\->\fBpoll()\fR with no handles always returns immediately .PP However, to integrate with existing code that uses an \f(CW\*(C`IO::Poll\*(C'\fR object, a \&\f(CW\*(C`post_poll\*(C'\fR can be called immediately after the \f(CW\*(C`poll\*(C'\fR method that \&\f(CW\*(C`IO::Poll\*(C'\fR object. The appropriate mask bits are maintained on the \&\f(CW\*(C`IO::Poll\*(C'\fR object when notifiers are added or removed from the loop, or when they change their \f(CW\*(C`want_*\*(C'\fR status. The \f(CW\*(C`post_poll\*(C'\fR method inspects the result bits and invokes the \f(CW\*(C`on_read_ready\*(C'\fR or \f(CW\*(C`on_write_ready\*(C'\fR methods on the notifiers. .SH CONSTRUCTOR .IX Header "CONSTRUCTOR" .SS new .IX Subsection "new" .Vb 1 \& $loop = IO::Async::Loop::Poll\->new( %args ); .Ve .PP This function returns a new instance of a \f(CW\*(C`IO::Async::Loop::Poll\*(C'\fR object. It takes the following named arguments: .ie n .IP """poll""" 8 .el .IP \f(CWpoll\fR 8 .IX Item "poll" The \f(CW\*(C`IO::Poll\*(C'\fR object to use for notification. Optional; if a value is not given, the underlying \f(CWIO::Poll::_poll()\fR function is invoked directly, outside of the object wrapping. .SH METHODS .IX Header "METHODS" .SS post_poll .IX Subsection "post_poll" .Vb 1 \& $count = $loop\->post_poll; .Ve .PP This method checks the returned event list from a \f(CW\*(C`IO::Poll::poll\*(C'\fR 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 \f(CW\*(C`on_read_ready\*(C'\fR and \f(CW\*(C`on_write_ready\*(C'\fR callbacks for \&\f(CW\*(C`watch_io\*(C'\fR, and \f(CW\*(C`watch_time\*(C'\fR event callbacks. .SS loop_once .IX Subsection "loop_once" .Vb 1 \& $count = $loop\->loop_once( $timeout ); .Ve .PP This method calls the \f(CW\*(C`poll\*(C'\fR method on the stored \f(CW\*(C`IO::Poll\*(C'\fR object, passing in the value of \f(CW$timeout\fR, and then runs the \f(CW\*(C`post_poll\*(C'\fR method on itself. It returns the total number of callbacks invoked by the \&\f(CW\*(C`post_poll\*(C'\fR method, or \f(CW\*(C`undef\*(C'\fR if the underlying \f(CW\*(C`poll\*(C'\fR method returned an error. .SH AUTHOR .IX Header "AUTHOR" Paul Evans