|
Webserv
|
Centralised event demultiplexer and dispatcher for managing I/O events. More...
#include <EventDispatcher.hpp>
Public Member Functions | |
| ~EventDispatcher () | |
| void | registerHandler (IEventHandler *handler) |
| void | removeHandler (IEventHandler *handler) |
| void | handleEvents () |
| void | requestShutdown () |
| void | enableRead (IEventHandler *handler) |
| Adds EPOLLIN to the monitored events. | |
| void | disableRead (IEventHandler *handler) |
| Removes EPOLLIN from the monitored events. | |
| void | enableWrite (IEventHandler *handler) |
| Adds EPOLLOUT to the monitored events. | |
| void | disableWrite (IEventHandler *handler) |
| Removes EPOLLOUT from the monitored events. | |
Static Public Member Functions | |
| static EventDispatcher & | getInstance () |
Private Member Functions | |
| void | updateEventMask (IEventHandler *handler, uint32_t newMask) |
| void | cleanUpGarbage () |
| EventDispatcher () | |
| EventDispatcher (const EventDispatcher &) | |
| EventDispatcher & | operator= (const EventDispatcher &) |
Private Attributes | |
| EpollManager | epollManager_ |
| std::map< int, IEventHandler * > | handlers_ |
| std::set< IEventHandler * > | pendingRemovals_ |
| std::set< IEventHandler * > | activeHandlers_ |
Centralised event demultiplexer and dispatcher for managing I/O events.
EventDispatcher coordinates between the event detection mechanism (epoll) and register event handlers. It maintains a registry of handlers, waits for events to occur on monitored file descriptors, and dispatches events to appropriate handlers. This implements the core of the ClientHandler pattern for non-blocking, event-driven I/O.
| network::EventDispatcher::~EventDispatcher | ( | ) |
|
private |
|
private |
|
private |
| void network::EventDispatcher::disableRead | ( | IEventHandler * | handler | ) |
Removes EPOLLIN from the monitored events.
| void network::EventDispatcher::disableWrite | ( | IEventHandler * | handler | ) |
Removes EPOLLOUT from the monitored events.
| void network::EventDispatcher::enableRead | ( | IEventHandler * | handler | ) |
Adds EPOLLIN to the monitored events.
| void network::EventDispatcher::enableWrite | ( | IEventHandler * | handler | ) |
Adds EPOLLOUT to the monitored events.
|
static |
| void network::EventDispatcher::handleEvents | ( | ) |
|
private |
| void network::EventDispatcher::registerHandler | ( | IEventHandler * | handler | ) |
| void network::EventDispatcher::removeHandler | ( | IEventHandler * | handler | ) |
| void network::EventDispatcher::requestShutdown | ( | ) |
|
private |
|
private |
|
private |
|
private |
|
private |