.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28) .\" .\" 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 .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . 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 turned on, 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 .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "IO::Epoll 3pm" .TH IO::Epoll 3pm "2014-08-15" "perl v5.20.0" "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::Epoll \- Scalable IO Multiplexing for Linux 2.5.44 and higher .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& # Low level interface \& use IO::Epoll; \& \& $epfd = epoll_create(10); \& \& epoll_ctl($epfd, EPOLL_CTL_ADD, fileno STDIN, EPOLLIN) >= 0 \& || die "epoll_ctl: $!\en"; \& epoll_ctl($epfd, ...); \& \& $events = epoll_wait($epfd, 10, 1000); # Max 10 events returned, 1s timeout \& \& # High level IO::Poll emulation layer \& use IO::EPoll qw(:compat); \& \& $poll = new IO::Epoll; \& \& $poll\->mask($input_handle => POLLIN); \& $poll\->mask($output_handle => POLLOUT); \& \& $poll\->poll($timeout); \& \& $ev = $poll\->events($input); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \f(CWepoll(4)\fR subsystem is a new, (currently) Linux-specific variant of \&\f(CWpoll(2)\fR. It is designed to offer O(1) scalability over large numbers of watched file descriptors. You will need at least version 2.5.44 of Linux to use this module, and you might need to upgrade your C library. .PP The \f(CWepoll(2)\fR \s-1API\s0 comprises four system calls: \f(CWepoll_create(2)\fR, \&\f(CWepoll_ctl(2)\fR, \f(CWepoll_wait(2)\fR and \f(CWepoll_pwait(2)\fR. \f(CW\*(C`IO::Epoll\*(C'\fR provides a low-level \s-1API\s0 which closely matches the underlying system calls. It also provides a higher-level layer designed to emulate the behavior of \&\f(CW\*(C`IO::Poll\*(C'\fR and \f(CW\*(C`IO::Ppoll\*(C'\fR. .SH "LOW-LEVEL API" .IX Header "LOW-LEVEL API" .SS "epoll_create" .IX Subsection "epoll_create" Create a new \f(CW\*(C`epoll\*(C'\fR file descriptor by requesting the kernel allocate an event backing store dimensioned for \f(CW\*(C`size\*(C'\fR descriptors. The size is not the maximum size of the backing store but just a hint to the kernel about how to dimension internal structures. The returned file descriptor will be used for all the subsequent calls to the \f(CW\*(C`epoll\*(C'\fR interface. The file descriptor returned by \&\f(CW\*(C`epoll_create\*(C'\fR must be closed by using \f(CW\*(C`POSIX::close\*(C'\fR. .PP .Vb 3 \& $epfd = epoll_create(15); \& ... \& POSIX::close($epfd); .Ve .PP When successful, \f(CW\*(C`epoll_create\*(C'\fR returns a positive integer identifying the descriptor. When an error occurs, \f(CW\*(C`epoll_create\*(C'\fR returns \-1 and errno is set appropriately. .SS "epoll_ctl" .IX Subsection "epoll_ctl" Control an \f(CW\*(C`epoll\*(C'\fR descriptor, \f(CW$epfd\fR, by requesting the operation op be performed on the target file descriptor, fd. .PP .Vb 1 \& $ret = epoll_ctl($epfd, $op, $fd, $eventmask) .Ve .PP \&\f(CW$epfd\fR is an \f(CW\*(C`epoll\*(C'\fR descriptor returned from \f(CW\*(C`epoll_create\*(C'\fR. .PP \&\f(CW$op\fR is one of \f(CW\*(C`EPOLL_CTL_ADD\*(C'\fR, \f(CW\*(C`EPOLL_CTL_MOD\*(C'\fR or \f(CW\*(C`EPOLL_CTL_DEL\*(C'\fR. .PP \&\f(CW$fd\fR is the file desciptor to be watched. .PP \&\f(CW$eventmask\fR is a bitmask of events defined by \f(CW\*(C`EPOLLIN\*(C'\fR, \f(CW\*(C`EPOLLOUT\*(C'\fR, etc. .PP When successful, \f(CW\*(C`epoll_ctl\*(C'\fR returns 0. When an error occurs, \&\f(CW\*(C`epoll_ctl\*(C'\fR returns \-1 and errno is set appropriately. .SS "epoll_wait" .IX Subsection "epoll_wait" Wait for events on the \f(CW\*(C`epoll\*(C'\fR file descriptor \f(CW$epfd\fR. .PP .Vb 1 \& $ret = epoll_wait($epfd, $maxevents, $timeout) .Ve .PP \&\f(CW$epfd\fR is an \f(CW\*(C`epoll\*(C'\fR descriptor returned from \f(CW\*(C`epoll_create\*(C'\fR. .PP \&\f(CW$maxevents\fR is an integer specifying the maximum number of events to be returned. .PP \&\f(CW$timeout\fR is a timeout, in milliseconds .PP When successful, \f(CW\*(C`epoll_wait\*(C'\fR returns a reference to an array of events. Each event is a two element array, the first element being the file descriptor which triggered the event, and the second is the mask of event types triggered. For example, if \f(CW\*(C`epoll_wait\*(C'\fR returned the following data structure: .PP .Vb 4 \& [ \& [ 0, EPOLLIN ], \& [ 6, EPOLLOUT | EPOLLIN ] \& ] .Ve .PP then file descriptor 0 would be ready for reading, and fd 4 would be ready for both reading and writing. .PP On error, \f(CW\*(C`epoll_wait\*(C'\fR returns undef and sets \f(CW\*(C`errno\*(C'\fR appropriately. .SS "epoll_pwait" .IX Subsection "epoll_pwait" Wait for events on the \f(CW\*(C`epoll\*(C'\fR file descriptor \f(CW$epfd\fR. .PP .Vb 1 \& $ret = epoll_pwait($epfd, $maxevents, $timeout, $sigmask) .Ve .PP Identical to \f(CW\*(C`epoll_wait\*(C'\fR, except that the kernel will atomically swap the current signal mask for the process to that supplied in \f(CW$sigmask\fR, wait for events, then restore it to what it was originally. The \f(CW$sigmask\fR parameter should be undef, or an instance of \f(CW\*(C`POSIX::SigSet\*(C'\fR. .SH "HIGH LEVEL API" .IX Header "HIGH LEVEL API" IO::Epoll provides an object oriented \s-1API\s0 designed to be a drop-in replacement for IO::Poll. See the documentation for that module for more information. .SH "METHODS" .IX Header "METHODS" .IP "mask ( \s-1IO\s0 [, \s-1EVENT_MASK \s0] )" 4 .IX Item "mask ( IO [, EVENT_MASK ] )" If \s-1EVENT_MASK\s0 is given, then, if \s-1EVENT_MASK\s0 is non-zero, \s-1IO\s0 is added to the list of file descriptors and the next call to poll will check for any event specified in \s-1EVENT_MASK.\s0 If \s-1EVENT_MASK\s0 is zero then \s-1IO\s0 will be removed from the list of file descriptors. .Sp If \s-1EVENT_MASK\s0 is not given then the return value will be the current event mask value for \s-1IO.\s0 .IP "poll ( [ \s-1TIMEOUT \s0] )" 4 .IX Item "poll ( [ TIMEOUT ] )" Call the system level poll routine. If \s-1TIMEOUT\s0 is not specified then the call will block. Returns the number of handles which had events happen, or \-1 on error. \s-1TIMEOUT\s0 is in seconds and may be fractional. .IP "events ( \s-1IO \s0)" 4 .IX Item "events ( IO )" Returns the event mask which represents the events that happend on \s-1IO\s0 during the last call to \f(CW\*(C`poll\*(C'\fR. .IP "remove ( \s-1IO \s0)" 4 .IX Item "remove ( IO )" Remove \s-1IO\s0 from the list of file descriptors for the next poll. .IP "handles( [ \s-1EVENT_MASK \s0] )" 4 .IX Item "handles( [ EVENT_MASK ] )" Returns a list of handles. If \s-1EVENT_MASK\s0 is not given then a list of all handles known will be returned. If \s-1EVENT_MASK\s0 is given then a list of handles will be returned which had one of the events specified by \&\s-1EVENT_MASK\s0 happen during the last call ti \f(CW\*(C`poll\*(C'\fR .SH "IO::Ppoll METHODS" .IX Header "IO::Ppoll METHODS" IO::Epoll also provides methods compatible with IO::Ppoll. When any of these methods are called, the IO::Epoll object switches up to IO::Ppoll\-compatible mode, and will use the \f(CWepoll_pwait(2)\fR system call when the \f(CW\*(C`poll\*(C'\fR method is invoked. .IP "sigmask" 4 .IX Item "sigmask" Returns the \f(CW\*(C`POSIX::SigSet\*(C'\fR object in which the signal mask is stored. Since this is a reference to the object used in the call to \f(CWepoll_pwait(2)\fR, any modifications made to it will be reflected in the signal mask given to the system call. .IP "sigmask_add ( \s-1SIGNALS \s0)" 4 .IX Item "sigmask_add ( SIGNALS )" Adds the given signals to the signal mask. These signals will be blocked during the \f(CW\*(C`poll\*(C'\fR call. .IP "sigmask_del ( \s-1SIGNALS \s0)" 4 .IX Item "sigmask_del ( SIGNALS )" Removes the given signals from the signal mask. These signals will not be blocked during the \f(CW\*(C`poll\*(C'\fR call, and may be delivered while \f(CW\*(C`poll\*(C'\fR is waiting. .IP "sigmask_ismember ( \s-1SIGNAL \s0)" 4 .IX Item "sigmask_ismember ( SIGNAL )" Tests if the given signal is present in the signal mask. .SH "Exportable constants" .IX Header "Exportable constants" Exported by default: .PP .Vb 10 \& EPOLLERR \& EPOLLET \& EPOLLHUP \& EPOLLIN \& EPOLLMSG \& EPOLLOUT \& EPOLLPRI \& EPOLLRDBAND \& EPOLLRDNORM \& EPOLLWRBAND \& EPOLLWRNORM \& EPOLL_CTL_ADD \& EPOLL_CTL_DEL \& EPOLL_CTL_MOD .Ve .PP Exported by the :compat tag: .PP .Vb 10 \& POLLNVAL \& POLLIN \& POLLOUT \& POLLERR \& POLLHUP \& POLLPRI \& POLLRDNORM \& POLLWRNORM \& POLLRDBAND \& POLLWRBAND .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\f(CW\*(C`IO::Poll\*(C'\fR \f(CW\*(C`IO::Select\*(C'\fR \f(CW\*(C`IO::Ppoll\*(C'\fR \f(CWepoll(4)\fR \f(CWepoll_create(2)\fR \&\f(CWepoll_ctl(2)\fR \f(CWepoll_wait(2)\fR \f(CWepoll_pwait(2)\fR .SH "AUTHOR" .IX Header "AUTHOR" Bruce J Keeler, .SH "CREDITS" .IX Header "CREDITS" The \f(CW\*(C`IO::Poll\*(C'\fR compatibility code borrows heavily from the \f(CW\*(C`IO::Poll\*(C'\fR code itself, which was written by Graham Barr. .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright (C) 2004 by Bruce J. Keeler Portions Copyright (C) 1997\-8 Graham Barr .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.