X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/646c8fd6c0112573ba2aae7f165f5d48e849831e..c59911ca3cd38cf4ab36d2cc62686f97395899f9:/projects/stargazer/eventloop.h diff --git a/projects/stargazer/eventloop.h b/projects/stargazer/eventloop.h deleted file mode 100644 index 0b2b8397..00000000 --- a/projects/stargazer/eventloop.h +++ /dev/null @@ -1,45 +0,0 @@ -#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