dfx 0.1.0
Linux-based dynamic dataflow executor
Loading...
Searching...
No Matches
PollerProxy.hpp
1// SPDX-FileCopyrightText: 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 "NodeReactor.hpp"
13#include <dfx-core/Node.hpp>
14#include <dfx-fdwatch/Poller.hpp>
15
16namespace dfx::Runtime::Api
17{
47{
48public:
54 : _reactor { reactor }
55 , _node { node }
56 {}
57
58public:
66 void registerFd(Utils::BorrowedFd fd, FdWatch::EventInterests events, FdWatch::FdCallback cb) override
67 { _reactor.registerNodeFd(fd, events, std::move(cb), _node); }
68
74 void deregisterFd(Utils::BorrowedFd fd) noexcept override
75 { _reactor.deregisterNodeFd(fd); }
76
83 void updateFdEvents(Utils::BorrowedFd fd, FdWatch::EventInterests events) override
84 { _reactor.updateNodeFdEvents(fd, events); }
85
91 void deferCall(FdWatch::Callback cb) override
92 { _reactor.deferNodeCall(std::move(cb), _node); }
93
94private:
95 NodeReactor & _reactor;
96 Core::NodeWPtr _node;
97};
98} // !namespace dfx::Runtime::Api
Base class for all runtime-executed nodes in a dfx dataflow graph.
Abstract interface for FD-based event polling.
Definition Poller.hpp:37
Node-aware reactor API for FD watching and deferred execution in the runtime.
Definition NodeReactor.hpp:60
void deferCall(FdWatch::Callback cb) override
Schedule a callback to run later in the reactor context.
Definition PollerProxy.hpp:91
PollerProxy(Core::NodeWPtr node, NodeReactor &reactor)
Construct a poller proxy bound to a given node.
Definition PollerProxy.hpp:53
void deregisterFd(Utils::BorrowedFd fd) noexcept override
Deregister a previously registered file descriptor.
Definition PollerProxy.hpp:74
void updateFdEvents(Utils::BorrowedFd fd, FdWatch::EventInterests events) override
Update the list of event that this fd is attached to.
Definition PollerProxy.hpp:83
void registerFd(Utils::BorrowedFd fd, FdWatch::EventInterests events, FdWatch::FdCallback cb) override
Register a file descriptor for event notifications.
Definition PollerProxy.hpp:66
Non-owning wrapper around a file descriptor.
Definition BorrowedFd.hpp:33
std::weak_ptr< Node > NodeWPtr
Weak pointer type for Nodes.
Definition Node.hpp:66
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
Definition Node.hpp:48