/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* Epoll.hpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: acossari +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2026/08/26 11:34:23 by acossari #+# #+# */ /* Updated: 2026/08/26 11:34:25 by acossari ### ########.fr */ /* */ /* ************************************************************************** */ #pragma once #include #include #include #include #include #include #include #include "net/FileDescriptor.hpp" namespace webserv { class Epoll final { public: class Error : public std::exception { public: explicit Error(std::string message); const char* what() const noexcept override; private: std::string msg_; }; // wait() returns at most this many ready events per call. Smaller batches // require more calls, while larger batches delay the next loop iteration. // The value is a middle ground. Excess events remain for later calls. static constexpr std::size_t EVENT_BATCH_CAPACITY = 256; Epoll(); void add(int fd, std::uint32_t events, std::uint64_t token); void modify(int fd, std::uint32_t events, std::uint64_t token); void remove(int fd) noexcept; std::span wait(int timeoutMillis); private: FileDescriptor fd_; std::array events_{}; }; } // namespace webserv