11 void Poller::add_fd(int fd, std::function<int(int)> handler) {
12 pfds.emplace_back(pollfd{.fd = fd, .events = POLLIN, .revents = 0});
13 handlers.emplace_back(std::move(handler));
16 int Poller::check_events() {
18 if ((ret = poll(this->pfds.data(), this->pfds.size(), -1)) != -1 &&
20 for (unsigned i = 0; i < pfds.size(); i++) {
21 if ((pfds[i].revents & POLLIN) != 0) {
22 if (handlers[i](pfds[i].fd) == -1) {
26 pfds[i].events = POLLIN;
33 unique_fd::~unique_fd() {