1 #ifndef __EVENT_LOOP_H__
2 #define __EVENT_LOOP_H__
7 #include <condition_variable>
8 #pragma GCC diagnostic push
9 #pragma GCC diagnostic ignored "-Wshadow"
10 #include <jthread.hpp>
11 #pragma GCC diagnostic pop
16 static EVENT_LOOP& instance();
21 template <class ACTIVE_CLASS, typename DATA_TYPE>
22 void Enqueue(ACTIVE_CLASS & ac,
23 typename ACTOR<ACTIVE_CLASS, DATA_TYPE>::TYPE a,
26 std::lock_guard lock(m_mutex);
28 m_list.Enqueue(ac, a, d);
29 // Signal about new action
34 std::jthread m_thread;
36 std::condition_variable m_cond;
40 EVENT_LOOP() = default;
42 void Run(std::stop_token token);