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

Comparing libev/ev.pod (file contents):
Revision 1.96 by ayin, Fri Dec 21 10:06:50 2007 UTC vs.
Revision 1.97 by root, Sat Dec 22 05:48:02 2007 UTC

114=item ev_tstamp ev_time () 114=item ev_tstamp ev_time ()
115 115
116Returns the current time as libev would use it. Please note that the 116Returns the current time as libev would use it. Please note that the
117C<ev_now> function is usually faster and also often returns the timestamp 117C<ev_now> function is usually faster and also often returns the timestamp
118you actually want to know. 118you actually want to know.
119
120=item ev_sleep (ev_tstamp interval)
121
122Sleep for the given interval: The current thread will be blocked until
123either it is interrupted or the given time interval has passed. Basically
124this is a subsecond-resolution C<sleep ()>.
119 125
120=item int ev_version_major () 126=item int ev_version_major ()
121 127
122=item int ev_version_minor () 128=item int ev_version_minor ()
123 129
569Example: For some weird reason, unregister the above signal handler again. 575Example: For some weird reason, unregister the above signal handler again.
570 576
571 ev_ref (loop); 577 ev_ref (loop);
572 ev_signal_stop (loop, &exitsig); 578 ev_signal_stop (loop, &exitsig);
573 579
580=item ev_set_io_collect_interval (loop, ev_tstamp interval)
581
582=item ev_set_timeout_collect_interval (loop, ev_tstamp interval)
583
584These advanced functions influence the time that libev will spend waiting
585for events. Both are by default C<0>, meaning that libev will try to
586invoke timer/periodic callbacks and I/O callbacks with minimum latency.
587
588Setting these to a higher value (the C<interval> I<must> be >= C<0>)
589allows libev to delay invocation of I/O and timer/periodic callbacks to
590increase efficiency of loop iterations.
591
592The background is that sometimes your program runs just fast enough to
593handle one (or very few) event(s) per loop iteration. While this makes
594the program responsive, it also wastes a lot of CPU time to poll for new
595events, especially with backends like C<select ()> which have a high
596overhead for the actual polling but can deliver many events at once.
597
598By setting a higher I<io collect interval> you allow libev to spend more
599time collecting I/O events, so you can handle more events per iteration,
600at the cost of increasing latency. Timeouts (both C<ev_periodic> and
601C<ev_timer>) will be not affected.
602
603Likewise, by setting a higher I<timeout collect interval> you allow libev
604to spend more time collecting timeouts, at the expense of increased
605latency (the watcher callback will be called later). C<ev_io> watchers
606will not be affected.
607
608Many programs can usually benefit by setting the io collect interval to
609a value near C<0.1> or so, which is often enough for interactive servers
610(of course not for games), likewise for timeouts. It usually doesn't make
611much sense to set it to a lower value than C<0.01>, as this approsaches
612the timing granularity of most systems.
613
574=back 614=back
575 615
576 616
577=head1 ANATOMY OF A WATCHER 617=head1 ANATOMY OF A WATCHER
578 618
2297runtime if successful). Otherwise no use of the realtime clock option will 2337runtime if successful). Otherwise no use of the realtime clock option will
2298be attempted. This effectively replaces C<gettimeofday> by C<clock_get 2338be attempted. This effectively replaces C<gettimeofday> by C<clock_get
2299(CLOCK_REALTIME, ...)> and will not normally affect correctness. See the 2339(CLOCK_REALTIME, ...)> and will not normally affect correctness. See the
2300note about libraries in the description of C<EV_USE_MONOTONIC>, though. 2340note about libraries in the description of C<EV_USE_MONOTONIC>, though.
2301 2341
2342=item EV_USE_NANOSLEEP
2343
2344If defined to be C<1>, libev will assume that C<nanosleep ()> is available
2345and will use it for delays. Otherwise it will use C<select ()>.
2346
2302=item EV_USE_SELECT 2347=item EV_USE_SELECT
2303 2348
2304If undefined or defined to be C<1>, libev will compile in support for the 2349If undefined or defined to be C<1>, libev will compile in support for the
2305C<select>(2) backend. No attempt at autodetection will be done: if no 2350C<select>(2) backend. No attempt at autodetection will be done: if no
2306other method takes over, select will be it. Otherwise the select backend 2351other method takes over, select will be it. Otherwise the select backend

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines