… | |
… | |
189 | result in some caching, there is still a syscall per such incident |
189 | result in some caching, there is still a syscall per such incident |
190 | (because the fd could point to a different file description now), so its |
190 | (because the fd could point to a different file description now), so its |
191 | best to avoid that. Also, dup()ed file descriptors might not work very |
191 | best to avoid that. Also, dup()ed file descriptors might not work very |
192 | well if you register events for both fds. |
192 | well if you register events for both fds. |
193 | |
193 | |
|
|
194 | Please note that epoll sometimes generates spurious notifications, so you |
|
|
195 | need to use non-blocking I/O or other means to avoid blocking when no data |
|
|
196 | (or space) is available. |
|
|
197 | |
194 | =item C<EVBACKEND_KQUEUE> (value 8, most BSD clones) |
198 | =item C<EVBACKEND_KQUEUE> (value 8, most BSD clones) |
195 | |
199 | |
196 | Kqueue deserves special mention, as at the time of this writing, it |
200 | Kqueue deserves special mention, as at the time of this writing, it |
197 | was broken on all BSDs except NetBSD (usually it doesn't work with |
201 | was broken on all BSDs except NetBSD (usually it doesn't work with |
198 | anything but sockets and pipes, except on Darwin, where of course its |
202 | anything but sockets and pipes, except on Darwin, where of course its |
… | |
… | |
211 | |
215 | |
212 | =item C<EVBACKEND_PORT> (value 32, Solaris 10) |
216 | =item C<EVBACKEND_PORT> (value 32, Solaris 10) |
213 | |
217 | |
214 | This uses the Solaris 10 port mechanism. As with everything on Solaris, |
218 | This uses the Solaris 10 port mechanism. As with everything on Solaris, |
215 | it's really slow, but it still scales very well (O(active_fds)). |
219 | it's really slow, but it still scales very well (O(active_fds)). |
|
|
220 | |
|
|
221 | Please note that solaris ports can result in a lot of spurious |
|
|
222 | notifications, so you need to use non-blocking I/O or other means to avoid |
|
|
223 | blocking when no data (or space) is available. |
216 | |
224 | |
217 | =item C<EVBACKEND_ALL> |
225 | =item C<EVBACKEND_ALL> |
218 | |
226 | |
219 | Try all backends (even potentially broken ones that wouldn't be tried |
227 | Try all backends (even potentially broken ones that wouldn't be tried |
220 | with C<EVFLAG_AUTO>). Since this is a mask, you can do stuff such as |
228 | with C<EVFLAG_AUTO>). Since this is a mask, you can do stuff such as |
… | |
… | |
528 | |
536 | |
529 | Configures an C<ev_io> watcher. The fd is the file descriptor to rceeive |
537 | Configures an C<ev_io> watcher. The fd is the file descriptor to rceeive |
530 | events for and events is either C<EV_READ>, C<EV_WRITE> or C<EV_READ | |
538 | events for and events is either C<EV_READ>, C<EV_WRITE> or C<EV_READ | |
531 | EV_WRITE> to receive the given events. |
539 | EV_WRITE> to receive the given events. |
532 | |
540 | |
|
|
541 | Please note that most of the more scalable backend mechanisms (for example |
|
|
542 | epoll and solaris ports) can result in spurious readyness notifications |
|
|
543 | for file descriptors, so you practically need to use non-blocking I/O (and |
|
|
544 | treat callback invocation as hint only), or retest separately with a safe |
|
|
545 | interface before doing I/O (XLib can do this), or force the use of either |
|
|
546 | C<EVBACKEND_SELECT> or C<EVBACKEND_POLL>, which don't suffer from this |
|
|
547 | problem. Also note that it is quite easy to have your callback invoked |
|
|
548 | when the readyness condition is no longer valid even when employing |
|
|
549 | typical ways of handling events, so its a good idea to use non-blocking |
|
|
550 | I/O unconditionally. |
|
|
551 | |
533 | =back |
552 | =back |
534 | |
553 | |
535 | =head2 C<ev_timer> - relative and optionally recurring timeouts |
554 | =head2 C<ev_timer> - relative and optionally recurring timeouts |
536 | |
555 | |
537 | Timer watchers are simple relative timers that generate an event after a |
556 | Timer watchers are simple relative timers that generate an event after a |