… | |
… | |
302 | While stopping and starting an I/O watcher in the same iteration will |
302 | While stopping and starting an I/O watcher in the same iteration will |
303 | result in some caching, there is still a syscall per such incident |
303 | result in some caching, there is still a syscall per such incident |
304 | (because the fd could point to a different file description now), so its |
304 | (because the fd could point to a different file description now), so its |
305 | best to avoid that. Also, \fIdup()\fRed file descriptors might not work very |
305 | best to avoid that. Also, \fIdup()\fRed file descriptors might not work very |
306 | well if you register events for both fds. |
306 | well if you register events for both fds. |
|
|
307 | .Sp |
|
|
308 | Please note that epoll sometimes generates spurious notifications, so you |
|
|
309 | need to use non-blocking I/O or other means to avoid blocking when no data |
|
|
310 | (or space) is available. |
307 | .ie n .IP """EVBACKEND_KQUEUE"" (value 8, most \s-1BSD\s0 clones)" 4 |
311 | .ie n .IP """EVBACKEND_KQUEUE"" (value 8, most \s-1BSD\s0 clones)" 4 |
308 | .el .IP "\f(CWEVBACKEND_KQUEUE\fR (value 8, most \s-1BSD\s0 clones)" 4 |
312 | .el .IP "\f(CWEVBACKEND_KQUEUE\fR (value 8, most \s-1BSD\s0 clones)" 4 |
309 | .IX Item "EVBACKEND_KQUEUE (value 8, most BSD clones)" |
313 | .IX Item "EVBACKEND_KQUEUE (value 8, most BSD clones)" |
310 | Kqueue deserves special mention, as at the time of this writing, it |
314 | Kqueue deserves special mention, as at the time of this writing, it |
311 | was broken on all BSDs except NetBSD (usually it doesn't work with |
315 | was broken on all BSDs except NetBSD (usually it doesn't work with |
… | |
… | |
325 | .ie n .IP """EVBACKEND_PORT"" (value 32, Solaris 10)" 4 |
329 | .ie n .IP """EVBACKEND_PORT"" (value 32, Solaris 10)" 4 |
326 | .el .IP "\f(CWEVBACKEND_PORT\fR (value 32, Solaris 10)" 4 |
330 | .el .IP "\f(CWEVBACKEND_PORT\fR (value 32, Solaris 10)" 4 |
327 | .IX Item "EVBACKEND_PORT (value 32, Solaris 10)" |
331 | .IX Item "EVBACKEND_PORT (value 32, Solaris 10)" |
328 | This uses the Solaris 10 port mechanism. As with everything on Solaris, |
332 | This uses the Solaris 10 port mechanism. As with everything on Solaris, |
329 | it's really slow, but it still scales very well (O(active_fds)). |
333 | it's really slow, but it still scales very well (O(active_fds)). |
|
|
334 | .Sp |
|
|
335 | Please note that solaris ports can result in a lot of spurious |
|
|
336 | notifications, so you need to use non-blocking I/O or other means to avoid |
|
|
337 | blocking when no data (or space) is available. |
330 | .ie n .IP """EVBACKEND_ALL""" 4 |
338 | .ie n .IP """EVBACKEND_ALL""" 4 |
331 | .el .IP "\f(CWEVBACKEND_ALL\fR" 4 |
339 | .el .IP "\f(CWEVBACKEND_ALL\fR" 4 |
332 | .IX Item "EVBACKEND_ALL" |
340 | .IX Item "EVBACKEND_ALL" |
333 | Try all backends (even potentially broken ones that wouldn't be tried |
341 | Try all backends (even potentially broken ones that wouldn't be tried |
334 | with \f(CW\*(C`EVFLAG_AUTO\*(C'\fR). Since this is a mask, you can do stuff such as |
342 | with \f(CW\*(C`EVFLAG_AUTO\*(C'\fR). Since this is a mask, you can do stuff such as |
… | |
… | |
641 | .IX Item "ev_io_set (ev_io *, int fd, int events)" |
649 | .IX Item "ev_io_set (ev_io *, int fd, int events)" |
642 | .PD |
650 | .PD |
643 | Configures an \f(CW\*(C`ev_io\*(C'\fR watcher. The fd is the file descriptor to rceeive |
651 | Configures an \f(CW\*(C`ev_io\*(C'\fR watcher. The fd is the file descriptor to rceeive |
644 | events for and events is either \f(CW\*(C`EV_READ\*(C'\fR, \f(CW\*(C`EV_WRITE\*(C'\fR or \f(CW\*(C`EV_READ | |
652 | events for and events is either \f(CW\*(C`EV_READ\*(C'\fR, \f(CW\*(C`EV_WRITE\*(C'\fR or \f(CW\*(C`EV_READ | |
645 | EV_WRITE\*(C'\fR to receive the given events. |
653 | EV_WRITE\*(C'\fR to receive the given events. |
|
|
654 | .Sp |
|
|
655 | Please note that most of the more scalable backend mechanisms (for example |
|
|
656 | epoll and solaris ports) can result in spurious readyness notifications |
|
|
657 | for file descriptors, so you practically need to use non-blocking I/O (and |
|
|
658 | treat callback invocation as hint only), or retest separately with a safe |
|
|
659 | interface before doing I/O (XLib can do this), or force the use of either |
|
|
660 | \&\f(CW\*(C`EVBACKEND_SELECT\*(C'\fR or \f(CW\*(C`EVBACKEND_POLL\*(C'\fR, which don't suffer from this |
|
|
661 | problem. Also note that it is quite easy to have your callback invoked |
|
|
662 | when the readyness condition is no longer valid even when employing |
|
|
663 | typical ways of handling events, so its a good idea to use non-blocking |
|
|
664 | I/O unconditionally. |
646 | .ie n .Sh """ev_timer"" \- relative and optionally recurring timeouts" |
665 | .ie n .Sh """ev_timer"" \- relative and optionally recurring timeouts" |
647 | .el .Sh "\f(CWev_timer\fP \- relative and optionally recurring timeouts" |
666 | .el .Sh "\f(CWev_timer\fP \- relative and optionally recurring timeouts" |
648 | .IX Subsection "ev_timer - relative and optionally recurring timeouts" |
667 | .IX Subsection "ev_timer - relative and optionally recurring timeouts" |
649 | Timer watchers are simple relative timers that generate an event after a |
668 | Timer watchers are simple relative timers that generate an event after a |
650 | given time, and optionally repeating in regular intervals after that. |
669 | given time, and optionally repeating in regular intervals after that. |