X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/8c6fa3fbaccc22127280bf77a48fab5a3ee0716e..46b0747592074017ff0ea4b33d4a7194235886e5:/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