1Event::RPC::Loop(3)   User Contributed Perl Documentation  Event::RPC::Loop(3)
2
3
4

NAME

6       Event::RPC::Loop - Mainloop Abstraction layer for Event::RPC
7

SYNOPSIS

9         use Event::RPC::Server;
10         use Event::RPC::Loop::Glib;
11
12         my $server = Event::RPC::Server->new (
13             ...
14             loop => Event::RPC::Loop::Glib->new(),
15             ...
16         );
17
18         $server->start;
19

DESCRIPTION

21       This modules defines the interface of Event::RPC's mainloop abstraction
22       layer. It's a virtual class all mainloop modules should inherit from.
23

INTERFACE

25       The following methods need to be implemented:
26
27       $loop->enter ()
28           Enter resp. start a mainloop.
29
30       $loop->leave ()
31           Leave the mainloop, which was started with the enter() method.
32
33       $watcher = $loop->add_io_watcher ( %options )
34           Add an I/O watcher. Options are passed as a hash of key/value
35           pairs. The following options are known:
36
37           fh  The filehandle to be watched.
38
39           cb  This callback is called, without any parameters, if an event
40               occured on the filehandle above.
41
42           desc
43               A description of the watcher. Not necessarily implemented by
44               all modules, so it may be ignored.
45
46           poll
47               Either 'r', if your program reads from the filehandle, or 'w'
48               if it writes to it.
49
50           A watcher object is returned. What this exactly is depends on the
51           implementation, so you can't do anything useful with it besides
52           passing it back to del_io_watcher().
53
54       $loop->del_io_watcher ( $watcher )
55           Deletes an I/O watcher which was added with
56           $loop->add_io_watcher().
57
58       $timer = $loop->add_timer ( %options )
59           This sets a timer, a subroutine called after a specific timeout or
60           on a regularly basis with a fixed time interval.
61
62           Options are passed as a hash of key/value pairs. The following
63           options are known:
64
65           interval
66               A time interval in seconds, may be fractional.
67
68           after
69               Callback is called once after this amount of seconds, may be
70               fractional.
71
72           cb  The callback.
73
74           desc
75               A description of the timer. Not necessarily implemented by all
76               modules, so it may be ignored.
77
78           A timer object is returned. What this exactly is depends on the
79           implementation, so you can't do anything useful with it besides
80           passing it back to del_io_timer().
81
82       $loop->del_timer ( $timer )
83           Deletes a timer which was added with $loop->add_timer().
84

DIRECT USAGE IN YOUR SERVER

86       You may use the methods of Event::RPC::Loop by yourself if you like.
87       This way your program keeps independent of the actual mainloop module
88       in use, if the simplified interface of Event::RPC::Loop is sufficient
89       for you.
90
91       In your server program you access the actual mainloop object this way:
92
93         my $loop = Event::RPC::Server->instance->get_loop;
94
95       Naturally nothing speaks against making your program to work only with
96       a specific mainloop implementation, if you need its features. In that
97       case you may use the corresponding API directly (e.g. of Event or
98       Glib), no need to access it through Event::RPC::Loop.
99

AUTHORS

101         Jörn Reder <joern AT zyn.de>
102
104       Copyright (C) 2005-2015 by Jörn Reder <joern AT zyn.de>.
105
106       This library is free software; you can redistribute it and/or modify it
107       under the same terms as Perl itself.
108
109
110
111perl v5.30.1                      2020-01-30               Event::RPC::Loop(3)
Impressum