17#include <dfx-utilities/BorrowedFd.hpp>
19#include <dfx-utilities/OwnedFd.hpp>
69 using Callback = std::move_only_function<void (std::vector<FdInfo> fdInfos)>;
85 bool isRunning() const noexcept {
return _running.load(std::memory_order::relaxed); }
128 void _stop() noexcept;
131 void _listen(
std::stop_token stopToken) noexcept;
132 void _cleanup() noexcept;
135 Utils::OwnedFd _epfd;
136 Utils::OwnedFd _evtfd;
140 std::atomic_bool _running{
false};
141 std::jthread _listener;
Event interest and trigger flags for file-descriptor watching (Linux/epoll).
void updateFdEvents(Utils::BorrowedFd fd, FdWatch::EventInterests events)
Update the list of event that this fd is attached to.
void rearmFd(Utils::BorrowedFd fd, FdWatch::EventInterests events)
Rearm a previously registered FD.
~FdListener()
Stop the listener thread and release underlying resources.
bool isRunning() const noexcept
Whether the listener thread is currently running.
Definition FdListener.hpp:85
void registerFd(Utils::BorrowedFd fd, FdWatch::EventInterests events)
Register an FD with a set of interests.
void deregisterFd(Utils::BorrowedFd fd) noexcept
Deregister a previously registered FD.
std::move_only_function< void(std::vector< FdInfo > fdInfos)> Callback
Callback invoked for every observed FD event.
Definition FdListener.hpp:69
FdListener(Callback cb)
Construct and start the listener thread.
Non-owning wrapper around a file descriptor.
Definition BorrowedFd.hpp:33
Definition SystemConfigCommandHandler.hpp:15
Fd plus any associated information.
Definition FdListener.hpp:54
Utils::BorrowedFd fd
The actual FD in borrowed form.
Definition FdListener.hpp:56
FdWatch::EventInterests eventInterest
Event interest list attached to this FD.
Definition FdListener.hpp:62
FdWatch::EventTriggers events
Trigger event associated with the FD.
Definition FdListener.hpp:59