.\" -*- 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 "Linux::FD::Event 3pm" .TH Linux::FD::Event 3pm 2024-03-07 "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 Linux::FD::Event \- Event filehandles for Linux .SH VERSION .IX Header "VERSION" version 0.016 .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& use Linux::FD::Event; \& \& my $foo = Linux::FD::Event\->new(42); \& if (fork) { \& say $foo\->get while sleep 1 \& } \& else { \& $foo\->add($_) while <>; \& } .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" This creates an eventfd object that can be used as an event wait/notify mechanism by userspace applications, and by the kernel to notify userspace applications of events. The object contains an unsigned 64\-bit integer counter that is maintained by the kernel. It has two modes, default and semaphore, that differ only in \f(CW\*(C`get\*(C'\fR behavior as described below. .SH METHODS .IX Header "METHODS" .ie n .SS "new($initial_value, @flags)" .el .SS "new($initial_value, \f(CW@flags\fP)" .IX Subsection "new($initial_value, @flags)" This creates a new eventfd filehandler. The counter is initialized with the value specified in the argument \f(CW$initial_value\fR. \f(CW@flags\fR is an optional list of flags, currently limited to \f(CW\*(Aqnon\-blocking\*(Aq\fR (requires Linux 2.6.27), and \f(CW\*(Aqsemaphore\*(Aq\fR (requires Linux 2.6.30). .SS \fBget()\fP .IX Subsection "get()" If the eventfd counter has a non-zero value, and \f(CW\*(Aqsemaphore\*(Aq\fR is not set, then a \f(CW\*(C`get\*(C'\fR returns 64 bit unsigned integer containing that value, and the counter's value is reset to zero. If \f(CW\*(Aqsemaphore\*(Aq\fR is set, it decrements the counter by one and returns one. In either case, if the counter is zero at the time of the \f(CW\*(C`get\*(C'\fR, then the call either blocks until the counter becomes non-zero, or fails with the error EAGAIN if the file handle has been made non-blocking. .SS add($value) .IX Subsection "add($value)" A \f(CW\*(C`add\*(C'\fR call adds the 64 bit unsigned integer value \f(CW$value\fR to the counter. The maximum value that may be stored in the counter is the largest unsigned 64\-bit value minus 1 (i.e., 0xfffffffffffffffe). If the addition would cause the counter's value to exceed the maximum, then the \f(CW\*(C`add\*(C'\fR either blocks until a \f(CW\*(C`get\*(C'\fR is performed on the file descriptor, or fails with the error EAGAIN if the file descriptor has been made non-blocking. A \f(CW\*(C`add\*(C'\fR will fail with the error EINVAL if an attempt is made to write the value 0xffffffffffffffff. .SH AUTHOR .IX Header "AUTHOR" Leon Timmermans .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2010 by Leon Timmermans. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.