#pragma once // The event-loop wakeup primitive (docs/adr/0020, docs/08-porting.md). EventLoop uses this // to interrupt a blocked poll() from another thread or a signal handler — the eventfd // mechanics themselves are Linux-only; every other OS backend just needs something // poll()-able that signal()/drain() can drive the same way (docs/08 §"The seams": a // self-pipe on macOS, an event object on Windows). // // One implementation file per OS under platform//wakeup.cpp; this header carries no // OS types and no #ifdef (ADR 0020 decision 1). namespace velox::daemon::rpc::platform { class Wakeup { public: Wakeup(); ~Wakeup(); Wakeup(const Wakeup&) = delete; Wakeup& operator=(const Wakeup&) = delete; // The fd to register with poll(2) for readability. int pollfd() const noexcept { return fd_; } // Make pollfd() readable. Async-signal-safe and thread-safe. void signal() noexcept; // Drain whatever signal() queued so pollfd() stops being readable. Call this from the // loop thread once pollfd() fires. void drain() noexcept; private: int fd_ = -1; }; } // namespace velox::daemon::rpc::platform