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

Comparing libev/ev.pod (file contents):
Revision 1.52 by root, Tue Nov 27 19:41:52 2007 UTC vs.
Revision 1.53 by root, Tue Nov 27 20:15:02 2007 UTC

2 2
3libev - a high performance full-featured event loop written in C 3libev - a high performance full-featured event loop written in C
4 4
5=head1 SYNOPSIS 5=head1 SYNOPSIS
6 6
7 /* this is the only header you need */
7 #include <ev.h> 8 #include <ev.h>
9
10 /* what follows is a fully working example program */
11 ev_io stdin_watcher;
12 ev_timer timeout_watcher;
13
14 /* called when data readable on stdin */
15 static void
16 stdin_cb (EV_P_ struct ev_io *w, int revents)
17 {
18 /* puts ("stdin ready"); */
19 ev_io_stop (EV_A_ w); /* just a syntax example */
20 ev_unloop (EV_A_ EVUNLOOP_ALL); /* leave all loop calls */
21 }
22
23 static void
24 timeout_cb (EV_P_ struct ev_timer *w, int revents)
25 {
26 /* puts ("timeout"); */
27 ev_unloop (EV_A_ EVUNLOOP_ONE); /* leave one loop call */
28 }
29
30 int
31 main (void)
32 {
33 struct ev_loop *loop = ev_default_loop (0);
34
35 /* initialise an io watcher, then start it */
36 ev_io_init (&stdin_watcher, stdin_cb, /*STDIN_FILENO*/ 0, EV_READ);
37 ev_io_start (loop, &stdin_watcher);
38
39 /* simple non-repeating 5.5 second timeout */
40 ev_timer_init (&timeout_watcher, timeout_cb, 5.5, 0.);
41 ev_timer_start (loop, &timeout_watcher);
42
43 /* loop till timeout or data ready */
44 ev_loop (loop, 0);
45
46 return 0;
47 }
8 48
9=head1 DESCRIPTION 49=head1 DESCRIPTION
10 50
11Libev is an event loop: you register interest in certain events (such as a 51Libev 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 52file descriptor being readable or a timeout occuring), and it will manage

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines