X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/0907aa4037b12b6b88ee24495d4577a064d4f8db..c59911ca3cd38cf4ab36d2cc62686f97395899f9:/projects/stargazer/eventloop.h diff --git a/projects/stargazer/eventloop.h b/projects/stargazer/eventloop.h deleted file mode 100644 index 0e798142..00000000 --- a/projects/stargazer/eventloop.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef __EVENT_LOOP_H__ -#define __EVENT_LOOP_H__ - -#include - -#include "stg/noncopyable.h" -#include "actions.h" - -class EVENT_LOOP : private NONCOPYABLE, - private ACTIONS_LIST -{ - public: - bool Start(); - bool Stop(); - bool IsRunning() const { return _running; } - - template - void Enqueue(ACTIVE_CLASS & ac, - typename ACTOR::TYPE a, - DATA_TYPE d); - - private: - bool _running; - bool _stopped; - pthread_t _tid; - pthread_mutex_t _mutex; - pthread_cond_t _condition; - - EVENT_LOOP(); - virtual ~EVENT_LOOP(); - - static void * Run(void *); - void Runner(); - - friend class EVENT_LOOP_SINGLETON; -}; - -class EVENT_LOOP_SINGLETON : private NONCOPYABLE -{ - public: - static EVENT_LOOP & GetInstance(); - - private: - static EVENT_LOOP * _instance; - static void CreateInstance(); - - EVENT_LOOP_SINGLETON() {} - ~EVENT_LOOP_SINGLETON() {} -}; - -template -void EVENT_LOOP::Enqueue(ACTIVE_CLASS & ac, - typename ACTOR::TYPE a, - DATA_TYPE d) -{ -STG_LOCKER lock(&_mutex); -// Add new action -ACTIONS_LIST::Enqueue(ac, a, d); -// Signal about new action -pthread_cond_signal(&_condition); -} - -#endif