Full C++23 framework tree: runtime, observability, security, data, app, realtime, supervisor, clients, CLI, example plus enterprise tenancy, audit, operability, governance, supplychain. Postgres via docker compose for tests.
37 lines
1.2 KiB
C++
37 lines
1.2 KiB
C++
// 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 <cstddef>
|
|
#include <cstdint>
|
|
#include <functional>
|
|
#include <memory>
|
|
|
|
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<void(int fd, uint32_t events)>;
|
|
|
|
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<IPoller> MakePoller();
|
|
|
|
} // namespace molo::runtime
|