… | |
… | |
8 | |
8 | |
9 | =head1 DESCRIPTION |
9 | =head1 DESCRIPTION |
10 | |
10 | |
11 | Libev is an event loop: you register interest in certain events (such as a |
11 | Libev is an event loop: you register interest in certain events (such as a |
12 | file descriptor being readable or a timeout occuring), and it will manage |
12 | file descriptor being readable or a timeout occuring), and it will manage |
13 | these event sources and provide your program events. |
13 | these event sources and provide your program with events. |
14 | |
14 | |
15 | To do this, it must take more or less complete control over your process |
15 | To do this, it must take more or less complete control over your process |
16 | (or thread) by executing the I<event loop> handler, and will then |
16 | (or thread) by executing the I<event loop> handler, and will then |
17 | communicate events via a callback mechanism. |
17 | communicate events via a callback mechanism. |
18 | |
18 | |
… | |
… | |
293 | |
293 | |
294 | As long as your watcher is active (has been started but not stopped) you |
294 | As long as your watcher is active (has been started but not stopped) you |
295 | must not touch the values stored in it. Most specifically you must never |
295 | must not touch the values stored in it. Most specifically you must never |
296 | reinitialise it or call its set method. |
296 | reinitialise it or call its set method. |
297 | |
297 | |
298 | You cna check wether an event is active by calling the C<ev_is_active |
298 | You cna check whether an event is active by calling the C<ev_is_active |
299 | (watcher *)> macro. To see wether an event is outstanding (but the |
299 | (watcher *)> macro. To see whether an event is outstanding (but the |
300 | callback for it has not been called yet) you cna use the C<ev_is_pending |
300 | callback for it has not been called yet) you cna use the C<ev_is_pending |
301 | (watcher *)> macro. |
301 | (watcher *)> macro. |
302 | |
302 | |
303 | Each and every callback receives the event loop pointer as first, the |
303 | Each and every callback receives the event loop pointer as first, the |
304 | registered watcher structure as second, and a bitset of received events as |
304 | registered watcher structure as second, and a bitset of received events as |
… | |
… | |
400 | This section describes each watcher in detail, but will not repeat |
400 | This section describes each watcher in detail, but will not repeat |
401 | information given in the last section. |
401 | information given in the last section. |
402 | |
402 | |
403 | =head2 struct ev_io - is my file descriptor readable or writable |
403 | =head2 struct ev_io - is my file descriptor readable or writable |
404 | |
404 | |
405 | I/O watchers check wether a file descriptor is readable or writable |
405 | I/O watchers check whether a file descriptor is readable or writable |
406 | in each iteration of the event loop (This behaviour is called |
406 | in each iteration of the event loop (This behaviour is called |
407 | level-triggering because you keep receiving events as long as the |
407 | level-triggering because you keep receiving events as long as the |
408 | condition persists. Remember you cna stop the watcher if you don't want to |
408 | condition persists. Remember you cna stop the watcher if you don't want to |
409 | act on the event and neither want to receive future events). |
409 | act on the event and neither want to receive future events). |
410 | |
410 | |
… | |
… | |
467 | state where you do not expect data to travel on the socket, you can stop |
467 | state where you do not expect data to travel on the socket, you can stop |
468 | the timer, and again will automatically restart it if need be. |
468 | the timer, and again will automatically restart it if need be. |
469 | |
469 | |
470 | =back |
470 | =back |
471 | |
471 | |
472 | =head2 ev_periodic |
472 | =head2 ev_periodic - to cron or not to cron it |
473 | |
473 | |
474 | Periodic watchers are also timers of a kind, but they are very versatile |
474 | Periodic watchers are also timers of a kind, but they are very versatile |
475 | (and unfortunately a bit complex). |
475 | (and unfortunately a bit complex). |
476 | |
476 | |
477 | Unlike ev_timer's, they are not based on real time (or relative time) |
477 | Unlike ev_timer's, they are not based on real time (or relative time) |