From: ko1@... Date: 2020-08-17T09:49:09+00:00 Subject: [ruby-core:99611] [Ruby master Feature#17059] epoll as the backend of IO.select on Linux Issue #17059 has been updated by ko1 (Koichi Sasada). I want to know the general idea how to use `epoll` for `IO.select` backend. ```C #include #include #define _GNU_SOURCE #include #include #include #define N 2000 // 10k static void task_poll(int fds[]) { struct pollfd pfd[N]; for (int i=0; ifd = fds[i*2]; p->events = POLLIN; } int r = poll(&pfd[0], N, 0); if (r==0) { // timeout } else if (r>0) { for (int i=0; i static void task_epoll(int fds[]) { struct epoll_event events[N]; int efd = epoll_create(N); if (efd < 0) { perror("epoll"); exit(1); } for (int i=0; ievents = EPOLLIN; e->data.fd = fds[i*2]; if (epoll_ctl(efd, EPOLL_CTL_ADD, fds[i*2], e) < 0) { perror("epoll_ctl"); exit(1); } } int r = epoll_wait(efd, events, N, 0); if (r == 0) { // timeout } else if (r > 0) { for (int i=0; i