Webserv
Loading...
Searching...
No Matches
EventDispatcher.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "EpollManager.hpp"
4#include "IEventHandler.hpp"
5#include <map>
6#include <set>
7
8namespace network {
9
20public:
22
23 void registerHandler(IEventHandler *handler);
24 void removeHandler(IEventHandler *handler);
25 void handleEvents();
26 void requestShutdown();
27
29
30public:
35 void enableRead(IEventHandler *handler);
36
40 void disableRead(IEventHandler *handler);
41
46 void enableWrite(IEventHandler *handler);
47
51 void disableWrite(IEventHandler *handler);
52
53private:
54 void updateEventMask(IEventHandler *handler, uint32_t newMask);
55 void cleanUpGarbage();
56
57private:
59 std::map<int, IEventHandler *> handlers_;
60 std::set<IEventHandler *> pendingRemovals_;
61 std::set<IEventHandler *> activeHandlers_;
62
63private:
67};
68
69} // namespace network
Synchronous event demultiplexer that wraps Linux epoll for I/O event monitoring.
Definition EpollManager.hpp:19
std::set< IEventHandler * > pendingRemovals_
Definition EventDispatcher.hpp:60
~EventDispatcher()
Definition EventDispatcher.cpp:34
void enableWrite(IEventHandler *handler)
Adds EPOLLOUT to the monitored events.
Definition EventDispatcher.cpp:91
static EventDispatcher & getInstance()
Definition EventDispatcher.cpp:43
std::set< IEventHandler * > activeHandlers_
Definition EventDispatcher.hpp:61
void requestShutdown()
Definition EventDispatcher.cpp:76
void updateEventMask(IEventHandler *handler, uint32_t newMask)
Definition EventDispatcher.cpp:78
void handleEvents()
Definition EventDispatcher.cpp:108
EventDispatcher()
Definition EventDispatcher.cpp:32
EpollManager epollManager_
Definition EventDispatcher.hpp:58
void enableRead(IEventHandler *handler)
Adds EPOLLIN to the monitored events.
Definition EventDispatcher.cpp:86
void disableRead(IEventHandler *handler)
Removes EPOLLIN from the monitored events.
Definition EventDispatcher.cpp:96
void disableWrite(IEventHandler *handler)
Removes EPOLLOUT from the monitored events.
Definition EventDispatcher.cpp:101
EventDispatcher & operator=(const EventDispatcher &)
EventDispatcher(const EventDispatcher &)
void removeHandler(IEventHandler *handler)
Definition EventDispatcher.cpp:57
void registerHandler(IEventHandler *handler)
Definition EventDispatcher.cpp:48
void cleanUpGarbage()
Definition EventDispatcher.cpp:68
std::map< int, IEventHandler * > handlers_
Definition EventDispatcher.hpp:59
Abstract base class defining the interface for event-driven service handlers.
Definition IEventHandler.hpp:19
Definition Request.hpp:13