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