.\" Automatically generated by Pod::Man 4.14 (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 .. .\" 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 >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 "Event::RPC::Loop 3pm" .TH Event::RPC::Loop 3pm "2022-12-12" "perl v5.36.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" Event::RPC::Loop \- Mainloop Abstraction layer for Event::RPC .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& use Event::RPC::Server; \& use Event::RPC::Loop::Glib; \& \& my $server = Event::RPC::Server\->new ( \& ... \& loop => Event::RPC::Loop::Glib\->new(), \& ... \& ); \& \& $server\->start; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This modules defines the interface of Event::RPC's mainloop abstraction layer. It's a virtual class all mainloop modules should inherit from. .SH "INTERFACE" .IX Header "INTERFACE" The following methods need to be implemented: .ie n .IP "$loop\->\fBenter\fR ()" 4 .el .IP "\f(CW$loop\fR\->\fBenter\fR ()" 4 .IX Item "$loop->enter ()" Enter resp. start a mainloop. .ie n .IP "$loop\->\fBleave\fR ()" 4 .el .IP "\f(CW$loop\fR\->\fBleave\fR ()" 4 .IX Item "$loop->leave ()" Leave the mainloop, which was started with the \fBenter()\fR method. .ie n .IP "$watcher = $loop\->\fBadd_io_watcher\fR ( %options )" 4 .el .IP "\f(CW$watcher\fR = \f(CW$loop\fR\->\fBadd_io_watcher\fR ( \f(CW%options\fR )" 4 .IX Item "$watcher = $loop->add_io_watcher ( %options )" Add an I/O watcher. Options are passed as a hash of key/value pairs. The following options are known: .RS 4 .IP "\fBfh\fR" 4 .IX Item "fh" The filehandle to be watched. .IP "\fBcb\fR" 4 .IX Item "cb" This callback is called, without any parameters, if an event occurred on the filehandle above. .IP "\fBdesc\fR" 4 .IX Item "desc" A description of the watcher. Not necessarily implemented by all modules, so it may be ignored. .IP "\fBpoll\fR" 4 .IX Item "poll" Either 'r', if your program reads from the filehandle, or 'w' if it writes to it. .RE .RS 4 .Sp A watcher object is returned. What this exactly is depends on the implementation, so you can't do anything useful with it besides passing it back to \fBdel_io_watcher()\fR. .RE .ie n .IP "$loop\->\fBdel_io_watcher\fR ( $watcher )" 4 .el .IP "\f(CW$loop\fR\->\fBdel_io_watcher\fR ( \f(CW$watcher\fR )" 4 .IX Item "$loop->del_io_watcher ( $watcher )" Deletes an I/O watcher which was added with \f(CW$loop\fR\->\fBadd_io_watcher()\fR. .ie n .IP "$timer = $loop\->\fBadd_timer\fR ( %options )" 4 .el .IP "\f(CW$timer\fR = \f(CW$loop\fR\->\fBadd_timer\fR ( \f(CW%options\fR )" 4 .IX Item "$timer = $loop->add_timer ( %options )" This sets a timer, a subroutine called after a specific timeout or on a regularly basis with a fixed time interval. .Sp Options are passed as a hash of key/value pairs. The following options are known: .RS 4 .IP "\fBinterval\fR" 4 .IX Item "interval" A time interval in seconds, may be fractional. .IP "\fBafter\fR" 4 .IX Item "after" Callback is called once after this amount of seconds, may be fractional. .IP "\fBcb\fR" 4 .IX Item "cb" The callback. .IP "\fBdesc\fR" 4 .IX Item "desc" A description of the timer. Not necessarily implemented by all modules, so it may be ignored. .RE .RS 4 .Sp A timer object is returned. What this exactly is depends on the implementation, so you can't do anything useful with it besides passing it back to \fBdel_io_timer()\fR. .RE .ie n .IP "$loop\->\fBdel_timer\fR ( $timer )" 4 .el .IP "\f(CW$loop\fR\->\fBdel_timer\fR ( \f(CW$timer\fR )" 4 .IX Item "$loop->del_timer ( $timer )" Deletes a timer which was added with \f(CW$loop\fR\->\fBadd_timer()\fR. .SH "DIRECT USAGE IN YOUR SERVER" .IX Header "DIRECT USAGE IN YOUR SERVER" You may use the methods of Event::RPC::Loop by yourself if you like. This way your program keeps independent of the actual mainloop module in use, if the simplified interface of Event::RPC::Loop is sufficient for you. .PP In your server program you access the actual mainloop object this way: .PP .Vb 1 \& my $loop = Event::RPC::Server\->instance\->get_loop; .Ve .PP Naturally nothing speaks against making your program to work only with a specific mainloop implementation, if you need its features. In that case you may use the corresponding \s-1API\s0 directly (e.g. of Event or Glib), no need to access it through Event::RPC::Loop. .SH "AUTHORS" .IX Header "AUTHORS" .Vb 1 \& Jörn Reder .Ve .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright (C) 2005\-2015 by Jörn Reder . .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.