15#include "BorrowedFd.hpp"
16#include "Callback.hpp"
91 bool operator==(
PollerFd const &) const noexcept = delete;
92 bool operator!=(
PollerFd const &) const noexcept = delete;
94 bool operator==(
int fd) const noexcept {
return _fd.get() == fd; }
95 bool operator==(
BorrowedFd const & fd)
const noexcept {
return _fd.
get() == fd.get(); }
97 void swap(
PollerFd & other)
noexcept;
116 int get() const noexcept {
return _fd.get(); }
162 Poller * _poller =
nullptr;
164 bool _isRegistered = false;
174inline bool operator==(
int fd1, dfx::FdWatch::PollerFd
const & fd2)
noexcept {
return fd2 == fd1; }
177struct std::formatter<
dfx::FdWatch::PollerFd> :
public formatter<int>
180 {
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).
Non-owning wrapper around a file descriptor.
Definition BorrowedFd.hpp:37
Bitset wrapper for dfx::FdWatch::EventInterest values.
Owning RAII wrapper around a file descriptor.
Definition OwnedFd.hpp:36
int get() const noexcept
Get the owned file descriptor.
Definition OwnedFd.hpp:75
RAII wrapper for the registration of a FD in a Poller.
Definition PollerFd.hpp:42
void attach(Poller &poller, OwnedFd fd, EventInterests events, FdCallback cb)
Attaches this object to poller and adopts fd, registering it.
BorrowedFd borrow() const noexcept
Returns a non-owning view of the underlying FD.
Definition PollerFd.hpp:104
Poller * poller() const noexcept
Returns the poller this FD is currently associated with (if any).
Definition PollerFd.hpp:109
void registerTo(Poller &poller, EventInterests events, FdCallback cb)
Registers the currently owned FD into poller.
void reset() noexcept
Fully releases resources: deregisters (if needed), drops poller association, and closes/releases the ...
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:116
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:112
void deregister() noexcept
Deregisters this FD from its poller (if registered).
DISABLE_COPY(PollerFd)
Copying is disabled because this type owns the FD.
Abstract interface for FD-based event polling.
Definition Poller.hpp:37
Definition SocketClient.hpp:23
std::function< void(BorrowedFd, EventTriggers)> FdCallback
Invoked when events occur on a watched file descriptor.
Definition Callback.hpp:28
PollerFd makePollerFd(Poller &poller, OwnedFd fd, EventInterests events, FdCallback cb) noexcept
Create a PollerFd and transfer FD ownership to it.
Definition PollerFd.hpp:168
Definition Message.hpp:21