15#include "Callback.hpp"
17#include <dfx-utilities/BorrowedFd.hpp>
19#include <dfx-utilities/OwnedFd.hpp>
98 bool operator==(
PollerFd const &) const noexcept = delete;
99 bool operator!=(
PollerFd const &) const noexcept = delete;
101 bool operator==(
int fd) const noexcept {
return _fd.get() == fd; }
104 void swap(
PollerFd & other)
noexcept;
123 int get() const noexcept {
return _fd.get(); }
184 Poller * _poller =
nullptr;
186 bool _isRegistered = false;
196inline bool operator==(
int fd1, dfx::FdWatch::PollerFd
const & fd2)
noexcept {
return fd2 == fd1; }
199struct std::formatter<
dfx::FdWatch::PollerFd> :
public formatter<int>
202 {
return formatter<int>::format(e.
get(), ctx); }
Convenience macros to explicitly control copy and move semantics.
Event interest and trigger flags for file-descriptor watching (Linux/epoll).
Bitset wrapper for dfx::FdWatch::EventInterest values.
RAII wrapper for the registration of a FD in a Poller.
Definition PollerFd.hpp:42
Poller * poller() const noexcept
Returns the poller this FD is currently associated with (if any).
Definition PollerFd.hpp:116
void updateEvents(EventInterests events)
Update the list of event that this fd is attached to.
void registerTo(Poller &poller, EventInterests events, FdCallback cb)
Registers the currently owned FD into poller.
void attach(Poller &poller, Utils::OwnedFd fd, EventInterests events, FdCallback cb)
Attaches this object to poller and adopts fd, registering it.
void reset() noexcept
Fully releases resources: deregisters (if needed), drops poller association, and closes/releases the ...
Utils::BorrowedFd borrow() const noexcept
Returns a non-owning view of the underlying FD.
Definition PollerFd.hpp:111
bool hasValidFd() const noexcept
Returns true if the internal fd is valid.
Definition PollerFd.hpp:130
PollerFd() noexcept=default
Constructs an empty handle with no poller association and no FD.
int get() const noexcept
Returns the raw integer FD owned by this object.
Definition PollerFd.hpp:123
void migrateTo(Poller &poller, EventInterests events, FdCallback cb)
Moves the registration from the current poller to poller.
bool isRegistered() const noexcept
Returns whether this FD is currently registered in a poller.
Definition PollerFd.hpp:119
void deregister() noexcept
Deregisters this FD from its poller (if registered).
DFX_DISABLE_COPY(PollerFd)
Copying is disabled because this type owns the FD.
Abstract interface for FD-based event polling.
Definition Poller.hpp:37
Non-owning wrapper around a file descriptor.
Definition BorrowedFd.hpp:33
Owning RAII wrapper around a file descriptor.
Definition OwnedFd.hpp:36
int get() const noexcept
Get the owned file descriptor.
Definition OwnedFd.hpp:75
Definition SocketClient.hpp:23
PollerFd makePollerFd(Poller &poller, Utils::OwnedFd fd, EventInterests events, FdCallback cb)
Create a PollerFd and transfer FD ownership to it.
Definition PollerFd.hpp:190
std::function< void(Utils::BorrowedFd, EventTriggers)> FdCallback
Invoked when events occur on a watched file descriptor.
Definition Callback.hpp:28
Definition SystemConfigCommandHandler.hpp:15
Definition Message.hpp:21