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

Comparing libev/ev.pod (file contents):
Revision 1.119 by root, Tue Jan 15 04:07:37 2008 UTC vs.
Revision 1.121 by root, Mon Jan 28 12:13:54 2008 UTC

1438 1438
1439=head3 Watcher-Specific Functions and Data Members 1439=head3 Watcher-Specific Functions and Data Members
1440 1440
1441=over 4 1441=over 4
1442 1442
1443=item ev_child_init (ev_child *, callback, int pid) 1443=item ev_child_init (ev_child *, callback, int pid, int trace)
1444 1444
1445=item ev_child_set (ev_child *, int pid) 1445=item ev_child_set (ev_child *, int pid, int trace)
1446 1446
1447Configures the watcher to wait for status changes of process C<pid> (or 1447Configures the watcher to wait for status changes of process C<pid> (or
1448I<any> process if C<pid> is specified as C<0>). The callback can look 1448I<any> process if C<pid> is specified as C<0>). The callback can look
1449at the C<rstatus> member of the C<ev_child> watcher structure to see 1449at the C<rstatus> member of the C<ev_child> watcher structure to see
1450the status word (use the macros from C<sys/wait.h> and see your systems 1450the status word (use the macros from C<sys/wait.h> and see your systems
1451C<waitpid> documentation). The C<rpid> member contains the pid of the 1451C<waitpid> documentation). The C<rpid> member contains the pid of the
1452process causing the status change. 1452process causing the status change. C<trace> must be either C<0> (only
1453activate the watcher when the process terminates) or C<1> (additionally
1454activate the watcher when the process is stopped or continued).
1453 1455
1454=item int pid [read-only] 1456=item int pid [read-only]
1455 1457
1456The process id this watcher watches out for, or C<0>, meaning any process id. 1458The process id this watcher watches out for, or C<0>, meaning any process id.
1457 1459
1693 static void 1695 static void
1694 idle_cb (struct ev_loop *loop, struct ev_idle *w, int revents) 1696 idle_cb (struct ev_loop *loop, struct ev_idle *w, int revents)
1695 { 1697 {
1696 free (w); 1698 free (w);
1697 // now do something you wanted to do when the program has 1699 // now do something you wanted to do when the program has
1698 // no longer asnything immediate to do. 1700 // no longer anything immediate to do.
1699 } 1701 }
1700 1702
1701 struct ev_idle *idle_watcher = malloc (sizeof (struct ev_idle)); 1703 struct ev_idle *idle_watcher = malloc (sizeof (struct ev_idle));
1702 ev_idle_init (idle_watcher, idle_cb); 1704 ev_idle_init (idle_watcher, idle_cb);
1703 ev_idle_start (loop, idle_cb); 1705 ev_idle_start (loop, idle_cb);
2280Example: Define a class with an IO and idle watcher, start one of them in 2282Example: Define a class with an IO and idle watcher, start one of them in
2281the constructor. 2283the constructor.
2282 2284
2283 class myclass 2285 class myclass
2284 { 2286 {
2285 ev_io io; void io_cb (ev::io &w, int revents); 2287 ev::io io; void io_cb (ev::io &w, int revents);
2286 ev_idle idle void idle_cb (ev::idle &w, int revents); 2288 ev:idle idle void idle_cb (ev::idle &w, int revents);
2287 2289
2288 myclass (); 2290 myclass (int fd)
2289 }
2290
2291 myclass::myclass (int fd)
2292 { 2291 {
2293 io .set <myclass, &myclass::io_cb > (this); 2292 io .set <myclass, &myclass::io_cb > (this);
2294 idle.set <myclass, &myclass::idle_cb> (this); 2293 idle.set <myclass, &myclass::idle_cb> (this);
2295 2294
2296 io.start (fd, ev::READ); 2295 io.start (fd, ev::READ);
2296 }
2297 } 2297 };
2298 2298
2299 2299
2300=head1 MACRO MAGIC 2300=head1 MACRO MAGIC
2301 2301
2302Libev can be compiled with a variety of options, the most fundamantal 2302Libev can be compiled with a variety of options, the most fundamantal

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines