#ifndef __EVENT_LOOP_H__ #define __EVENT_LOOP_H__ #include "actions.h" #include #include #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wshadow" #include #pragma GCC diagnostic pop class EVENT_LOOP { public: static EVENT_LOOP& instance(); bool Start(); bool Stop(); template void Enqueue(ACTIVE_CLASS & ac, typename ACTOR::TYPE a, DATA_TYPE d) { std::lock_guard lock(m_mutex); // Add new action m_list.Enqueue(ac, a, d); // Signal about new action m_cond.notify_all(); } private: std::jthread m_thread; std::mutex m_mutex; std::condition_variable m_cond; ACTIONS_LIST m_list; EVENT_LOOP() = default; void Run(std::stop_token token); }; #endif