| 1 | use crate::{backend, io}; |
| 2 | |
| 3 | pub use backend::event::poll_fd::{PollFd, PollFlags}; |
| 4 | |
| 5 | /// `poll(self.fds, timeout)`—Wait for events on lists of file descriptors. |
| 6 | /// |
| 7 | /// On macOS, `poll` doesn't work on fds for /dev/tty or /dev/null, however |
| 8 | /// [`select`] is available and does work on these fds. |
| 9 | /// |
| 10 | /// [`select`]: crate::event::select() |
| 11 | /// |
| 12 | /// # References |
| 13 | /// - [Beej's Guide to Network Programming] |
| 14 | /// - [POSIX] |
| 15 | /// - [Linux] |
| 16 | /// - [Apple] |
| 17 | /// - [Winsock] |
| 18 | /// - [FreeBSD] |
| 19 | /// - [NetBSD] |
| 20 | /// - [OpenBSD] |
| 21 | /// - [DragonFly BSD] |
| 22 | /// - [illumos] |
| 23 | /// |
| 24 | /// [Beej's Guide to Network Programming]: https://beej.us/guide/bgnet/html/split/slightly-advanced-techniques.html#poll |
| 25 | /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/poll.html |
| 26 | /// [Linux]: https://man7.org/linux/man-pages/man2/poll.2.html |
| 27 | /// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/poll.2.html |
| 28 | /// [Winsock]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsapoll |
| 29 | /// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=poll&sektion=2 |
| 30 | /// [NetBSD]: https://man.netbsd.org/poll.2 |
| 31 | /// [OpenBSD]: https://man.openbsd.org/poll.2 |
| 32 | /// [DragonFly BSD]: https://man.dragonflybsd.org/?command=poll§ion=2 |
| 33 | /// [illumos]: https://illumos.org/man/2/poll |
| 34 | #[inline ] |
| 35 | pub fn poll(fds: &mut [PollFd<'_>], timeout: i32) -> io::Result<usize> { |
| 36 | backend::event::syscalls::poll(fds, timeout) |
| 37 | } |
| 38 | |