dfx 0.1.0
Linux-based dynamic dataflow executor
Loading...
Searching...
No Matches
Poller.hpp
1// SPDX-FileCopyrightText: 2025-2026 Vincent Leroy
2// SPDX-License-Identifier: MIT
3//
4// This file is part of dfx.
5//
6// Licensed under the MIT License. See the LICENSE file in the project root
7// for full license information.
8
9#pragma once
10
11// Project includes
12#include "Callback.hpp"
13#include "Events.hpp"
14#include <dfx-utilities/BorrowedFd.hpp>
15
16namespace dfx::FdWatch
17{
36class Poller
37{
38public:
40 virtual ~Poller() = default;
41
55 virtual void registerFd(Utils::BorrowedFd fd, EventInterests events, FdCallback cb) = 0;
56
65 virtual void deregisterFd(Utils::BorrowedFd fd) noexcept = 0;
66
71 virtual void updateFdEvents(Utils::BorrowedFd fd, EventInterests events) = 0;
72
79 virtual void deferCall(Callback cb) = 0;
80};
81} // !namespace dfx::FdWatch
Event interest and trigger flags for file-descriptor watching (Linux/epoll).
Bitset wrapper for dfx::FdWatch::EventInterest values.
Abstract interface for FD-based event polling.
Definition Poller.hpp:37
virtual ~Poller()=default
Virtual destructor for interface.
virtual void updateFdEvents(Utils::BorrowedFd fd, EventInterests events)=0
Update the list of event that this fd is attached to.
virtual void registerFd(Utils::BorrowedFd fd, EventInterests events, FdCallback cb)=0
Registers a file descriptor with the poller.
virtual void deferCall(Callback cb)=0
Defer the call to the callback to the next time the event loop is reached.
virtual void deregisterFd(Utils::BorrowedFd fd) noexcept=0
Deregisters a file descriptor from the poller.
Non-owning wrapper around a file descriptor.
Definition BorrowedFd.hpp:33
Definition SocketClient.hpp:23
std::move_only_function< void()> Callback
Generic move-only callback with no arguments.
Definition Callback.hpp:31
std::function< void(Utils::BorrowedFd, EventTriggers)> FdCallback
Invoked when events occur on a watched file descriptor.
Definition Callback.hpp:28