// Spec: plans/01-runtime.md 6.1. One Poller interface hiding epoll, kqueue // and IOCP. Default is level-triggered for safety; edge-triggered stays // inside a Poller implementation with drain-to-EAGAIN. #pragma once #include #include #include #include namespace molo::runtime { class IPoller { public: static constexpr uint32_t kRead = 1u << 0; static constexpr uint32_t kWrite = 1u << 1; static constexpr uint32_t kError = 1u << 2; using Callback = std::function; virtual ~IPoller() = default; virtual bool add_fd(int fd, uint32_t events, Callback cb) = 0; virtual bool modify_fd(int fd, uint32_t events) = 0; virtual void remove_fd(int fd) = 0; // Blocks up to timeout_ms, dispatches callbacks, returns dispatched count. virtual int wait(int timeout_ms) = 0; // Thread-safe: wakes a thread blocked in wait(). virtual void wake() = 0; virtual std::size_t watched() const = 0; }; // Best Poller for the build platform. Never null; falls back to a stub that // reports failure when no backend exists (should not happen on supported OS). std::unique_ptr MakePoller(); } // namespace molo::runtime