ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.pod
(Generate patch)

Comparing libev/ev.pod (file contents):
Revision 1.1 by root, Mon Nov 12 07:58:13 2007 UTC vs.
Revision 1.4 by root, Mon Nov 12 08:11:01 2007 UTC

8 8
9=head1 DESCRIPTION 9=head1 DESCRIPTION
10 10
11Libev is an event loop: you register interest in certain events (such as a 11Libev is an event loop: you register interest in certain events (such as a
12file descriptor being readable or a timeout occuring), and it will manage 12file descriptor being readable or a timeout occuring), and it will manage
13these event sources and provide your program events. 13these event sources and provide your program with events.
14 14
15To do this, it must take more or less complete control over your process 15To 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
17communicate events via a callback mechanism. 17communicate events via a callback mechanism.
18 18
39argument of name C<loop> (which is always of type C<struct ev_loop *>) 39argument of name C<loop> (which is always of type C<struct ev_loop *>)
40will not have this argument. 40will not have this argument.
41 41
42=head1 TIME AND OTHER GLOBAL FUNCTIONS 42=head1 TIME AND OTHER GLOBAL FUNCTIONS
43 43
44Libev represents time as a single floating point number. This type is 44Libev represents time as a single floating point number, representing the
45(fractional) number of seconds since the (POSIX) epoch (somewhere near
46the beginning of 1970, details are complicated, don't ask). This type is
45called C<ev_tstamp>, which is what you should use too. It usually aliases 47called C<ev_tstamp>, which is what you should use too. It usually aliases
46to the double type in C. 48to the double type in C.
47 49
48=over 4 50=over 4
49 51
291 293
292As long as your watcher is active (has been started but not stopped) you 294As long as your watcher is active (has been started but not stopped) you
293must not touch the values stored in it. Most specifically you must never 295must not touch the values stored in it. Most specifically you must never
294reinitialise it or call its set method. 296reinitialise it or call its set method.
295 297
296You cna check wether an event is active by calling the C<ev_is_active 298You cna check whether an event is active by calling the C<ev_is_active
297(watcher *)> macro. To see wether an event is outstanding (but the 299(watcher *)> macro. To see whether an event is outstanding (but the
298callback for it has not been called yet) you cna use the C<ev_is_pending 300callback for it has not been called yet) you cna use the C<ev_is_pending
299(watcher *)> macro. 301(watcher *)> macro.
300 302
301Each and every callback receives the event loop pointer as first, the 303Each and every callback receives the event loop pointer as first, the
302registered watcher structure as second, and a bitset of received events as 304registered watcher structure as second, and a bitset of received events as
398This section describes each watcher in detail, but will not repeat 400This section describes each watcher in detail, but will not repeat
399information given in the last section. 401information given in the last section.
400 402
401=head2 struct ev_io - is my file descriptor readable or writable 403=head2 struct ev_io - is my file descriptor readable or writable
402 404
403I/O watchers check wether a file descriptor is readable or writable 405I/O watchers check whether a file descriptor is readable or writable
404in each iteration of the event loop (This behaviour is called 406in each iteration of the event loop (This behaviour is called
405level-triggering because you keep receiving events as long as the 407level-triggering because you keep receiving events as long as the
406condition persists. Remember you cna stop the watcher if you don't want to 408condition persists. Remember you cna stop the watcher if you don't want to
407act on the event and neither want to receive future events). 409act on the event and neither want to receive future events).
408 410
465state where you do not expect data to travel on the socket, you can stop 467state where you do not expect data to travel on the socket, you can stop
466the timer, and again will automatically restart it if need be. 468the timer, and again will automatically restart it if need be.
467 469
468=back 470=back
469 471
470=head2 ev_periodic 472=head2 ev_periodic - to cron or not to cron it
471 473
472Periodic watchers are also timers of a kind, but they are very versatile 474Periodic watchers are also timers of a kind, but they are very versatile
473(and unfortunately a bit complex). 475(and unfortunately a bit complex).
474 476
475Unlike ev_timer's, they are not based on real time (or relative time) 477Unlike ev_timer's, they are not based on real time (or relative time)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines