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

Comparing libev/ev.pod (file contents):
Revision 1.191 by root, Tue Sep 30 19:45:23 2008 UTC vs.
Revision 1.193 by root, Wed Oct 1 04:25:25 2008 UTC

2502=over 4 2502=over 4
2503 2503
2504=item ev_once (loop, int fd, int events, ev_tstamp timeout, callback) 2504=item ev_once (loop, int fd, int events, ev_tstamp timeout, callback)
2505 2505
2506This function combines a simple timer and an I/O watcher, calls your 2506This function combines a simple timer and an I/O watcher, calls your
2507callback on whichever event happens first and automatically stop both 2507callback on whichever event happens first and automatically stops both
2508watchers. This is useful if you want to wait for a single event on an fd 2508watchers. This is useful if you want to wait for a single event on an fd
2509or timeout without having to allocate/configure/start/stop/free one or 2509or timeout without having to allocate/configure/start/stop/free one or
2510more watchers yourself. 2510more watchers yourself.
2511 2511
2512If C<fd> is less than 0, then no I/O watcher will be started and events 2512If C<fd> is less than 0, then no I/O watcher will be started and the
2513is being ignored. Otherwise, an C<ev_io> watcher for the given C<fd> and 2513C<events> argument is being ignored. Otherwise, an C<ev_io> watcher for
2514C<events> set will be created and started. 2514the given C<fd> and C<events> set will be created and started.
2515 2515
2516If C<timeout> is less than 0, then no timeout watcher will be 2516If C<timeout> is less than 0, then no timeout watcher will be
2517started. Otherwise an C<ev_timer> watcher with after = C<timeout> (and 2517started. Otherwise an C<ev_timer> watcher with after = C<timeout> (and
2518repeat = 0) will be started. While C<0> is a valid timeout, it is of 2518repeat = 0) will be started. C<0> is a valid timeout.
2519dubious value.
2520 2519
2521The callback has the type C<void (*cb)(int revents, void *arg)> and gets 2520The callback has the type C<void (*cb)(int revents, void *arg)> and gets
2522passed an C<revents> set like normal event callbacks (a combination of 2521passed an C<revents> set like normal event callbacks (a combination of
2523C<EV_ERROR>, C<EV_READ>, C<EV_WRITE> or C<EV_TIMEOUT>) and the C<arg> 2522C<EV_ERROR>, C<EV_READ>, C<EV_WRITE> or C<EV_TIMEOUT>) and the C<arg>
2524value passed to C<ev_once>: 2523value passed to C<ev_once>. Note that it is possible to receive I<both>
2524a timeout and an io event at the same time - you probably should give io
2525events precedence.
2526
2527Example: wait up to ten seconds for data to appear on STDIN_FILENO.
2525 2528
2526 static void stdin_ready (int revents, void *arg) 2529 static void stdin_ready (int revents, void *arg)
2527 { 2530 {
2531 if (revents & EV_READ)
2532 /* stdin might have data for us, joy! */;
2528 if (revents & EV_TIMEOUT) 2533 else if (revents & EV_TIMEOUT)
2529 /* doh, nothing entered */; 2534 /* doh, nothing entered */;
2530 else if (revents & EV_READ)
2531 /* stdin might have data for us, joy! */;
2532 } 2535 }
2533 2536
2534 ev_once (STDIN_FILENO, EV_READ, 10., stdin_ready, 0); 2537 ev_once (STDIN_FILENO, EV_READ, 10., stdin_ready, 0);
2535 2538
2536=item ev_feed_event (ev_loop *, watcher *, int revents) 2539=item ev_feed_event (ev_loop *, watcher *, int revents)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines