39 #include "final/eventloop/monitor.h" 40 #include "final/util/fstring.h" 53 enum class PollResult : uInt8
80 auto getClassName()
const ->
FString;
84 void leave() noexcept;
88 static constexpr std::size_t DEFAULT_MONITOR_CAPACITY{64};
89 static constexpr
auto WAIT_INDEFINITELY{-1};
90 static constexpr
int POLL_WAIT_MS{1};
93 auto isRunning()
const noexcept -> bool;
94 auto isChanged()
const noexcept -> bool;
97 void reserveInitialCapacity();
98 void nonPollWaiting()
const noexcept;
99 void rebuildPollStructures();
100 auto processNextEvents() -> bool;
101 auto processPoll (
int&) -> PollResult;
102 void dispatcher (
int, nfds_t);
107 std::atomic<bool> running{
false};
108 std::atomic<bool> monitors_changed{
false};
109 std::vector<Monitor*> monitors{};
112 std::vector<struct pollfd> cached_fds{};
113 std::vector<Monitor*> cached_lookup{};
121 inline auto EventLoop::getClassName()
const ->
FString 122 {
return "EventLoop"; }
125 inline void EventLoop::leave() noexcept
126 { running.store(
false); }
129 inline auto EventLoop::isRunning()
const noexcept ->
bool 130 {
return running.load(); }
133 inline auto EventLoop::isChanged()
const noexcept ->
bool 134 {
return monitors_changed.load(); }
137 inline void EventLoop::reserveInitialCapacity()
140 monitors.reserve(DEFAULT_MONITOR_CAPACITY);
141 cached_fds.reserve(DEFAULT_MONITOR_CAPACITY);
142 cached_lookup.reserve(DEFAULT_MONITOR_CAPACITY);
147 #endif // EVENTLOOP_H
Definition: eventloop.h:49
Definition: class_template.cpp:25