diff options
| author | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2024-04-07 03:31:51 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-07 03:31:51 +0100 |
| commit | f2a848cbcc41f29fb62ee67aef95136ae1a650da (patch) | |
| tree | 6af50d58aa94fbb48880694a76f6edb79fa370ed /src/managers/eventLoop/EventLoopManager.hpp | |
| parent | 9f1604e4b0afec40cfa9bc095d6613a7f749b2c1 (diff) | |
core: Event loop rework (#5466)
* Event loop rework
* revert missed
Diffstat (limited to 'src/managers/eventLoop/EventLoopManager.hpp')
| -rw-r--r-- | src/managers/eventLoop/EventLoopManager.hpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/managers/eventLoop/EventLoopManager.hpp b/src/managers/eventLoop/EventLoopManager.hpp new file mode 100644 index 00000000..d55b54a9 --- /dev/null +++ b/src/managers/eventLoop/EventLoopManager.hpp @@ -0,0 +1,46 @@ +#pragma once + +#include <condition_variable> +#include <mutex> +#include <memory> +#include <thread> +#include <wayland-server.h> + +#include "EventLoopTimer.hpp" + +class CEventLoopManager { + public: + void enterLoop(wl_display* display, wl_event_loop* wlEventLoop); + void addTimer(std::shared_ptr<CEventLoopTimer> timer); + void removeTimer(std::shared_ptr<CEventLoopTimer> timer); + + // recalculates timers + void nudgeTimers(); + + private: + struct { + wl_event_loop* loop = nullptr; + wl_display* display = nullptr; + std::thread pollThread; + } m_sWayland; + + struct { + std::mutex timersMutex; + std::mutex timersRqMutex; + std::vector<std::shared_ptr<CEventLoopTimer>> timers; + std::thread timerThread; + bool event = false; + std::condition_variable cv; + } m_sTimers; + + struct { + std::mutex loopMutex; + std::mutex eventRequestMutex; + bool event = false; + std::condition_variable cv; + } m_sLoopState; + + bool m_bTerminate = false; +}; + +inline std::unique_ptr<CEventLoopManager> g_pEventLoopManager;
\ No newline at end of file |
