![]() |
dfx 0.1.0
Linux-based dynamic dataflow executor
|
epoll-based implementation of Poller. More...
#include <dfx-fdwatch/EPollPoller.hpp>
Public Member Functions | |
| EPollPoller () | |
| Constructs the poller and initializes underlying kernel resources. | |
| DISABLE_COPY_AND_MOVE (EPollPoller) | |
| Non-copyable, non-movable. | |
| ~EPollPoller () | |
| Destroys the poller and releases kernel resources. The poller must not be running while being destroyed. | |
| void | registerFd (BorrowedFd fd, EventInterests events, FdCallback cb) override |
| Registers a file descriptor with the poller. | |
| void | deregisterFd (BorrowedFd fd) noexcept override |
| Deregisters a file descriptor from the poller. | |
| void | deferCall (Callback cb) override |
| Defer the call to the callback to the next time the event loop is reached. | |
| void | exec () |
| Runs the event loop until stopping is requested. | |
| void | requestStop () noexcept |
| Requests the event loop to stop (non-blocking). | |
| void | stop () |
| Stops the event loop. | |
| void | wake () |
| Wakes the event loop. Useful when a stop has been requested while the loop is blocked in epoll_wait(). | |
| bool | isRunning () const noexcept |
| Returns whether the event loop is currently running. | |
| Public Member Functions inherited from dfx::FdWatch::Poller | |
| virtual | ~Poller ()=default |
| Virtual destructor for interface. | |
epoll-based implementation of Poller.
EPollPoller is the concrete event loop used by dfx to monitor file descriptors and dispatch callbacks when I/O readiness events occur.
It implements the Poller interface:
The main loop is driven by exec(). It blocks waiting for events and invokes the registered callbacks when events are received.
Internally, it uses an epoll instance FD and a wakeup FD (commonly eventfd) to interrupt epoll_wait() when work is deferred or when stopping is requested.
| dfx::FdWatch::EPollPoller::EPollPoller | ( | ) |
Constructs the poller and initializes underlying kernel resources.
Creates the epoll instance and the wakeup FD used by wake() and deferCall().
| dfx::FdWatch::EPollPoller::~EPollPoller | ( | ) |
Destroys the poller and releases kernel resources. The poller must not be running while being destroyed.
|
overridevirtual |
Defer the call to the callback to the next time the event loop is reached.
The callback will be invoked as soon as all currently pending event in the event loop have been processed.
| cb | Callback to be invoked later. |
Implements dfx::FdWatch::Poller.
|
overridevirtualnoexcept |
Deregisters a file descriptor from the poller.
After this call, the poller will no longer monitor the FD and no callbacks will be triggered for it.
| fd | Borrowed file descriptor to remove. |
Implements dfx::FdWatch::Poller.
| dfx::FdWatch::EPollPoller::DISABLE_COPY_AND_MOVE | ( | EPollPoller | ) |
Non-copyable, non-movable.
The poller owns kernel resources and maintains registrations that cannot be safely duplicated or transferred.
| void dfx::FdWatch::EPollPoller::exec | ( | ) |
Runs the event loop until stopping is requested.
This call blocks, processing registered FD events and executing deferred callbacks until requestStop() or stop() is used.
|
inlinenoexcept |
Returns whether the event loop is currently running.
|
overridevirtual |
Registers a file descriptor with the poller.
Once registered, the poller will monitor fd for the specified events and invoke cb when they occur.
| fd | Borrowed file descriptor to monitor. |
| events | Events of interest. |
| cb | Callback invoked when events occur. |
fd must refer to a valid, open file descriptor. Implements dfx::FdWatch::Poller.
|
noexcept |
Requests the event loop to stop (non-blocking).
| void dfx::FdWatch::EPollPoller::stop | ( | ) |
Stops the event loop.
Perform the requestStop and wake operation in sequence
| void dfx::FdWatch::EPollPoller::wake | ( | ) |
Wakes the event loop. Useful when a stop has been requested while the loop is blocked in epoll_wait().