From 66c5fdc564dd892ed265132d6c1378dbe3cebcee Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 27 Mar 2019 09:07:54 +0800 Subject: *misc --- source/libs/asura-lib-utils/threading/thread.h | 60 ++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 source/libs/asura-lib-utils/threading/thread.h (limited to 'source/libs/asura-lib-utils/threading/thread.h') diff --git a/source/libs/asura-lib-utils/threading/thread.h b/source/libs/asura-lib-utils/threading/thread.h new file mode 100644 index 0000000..0058144 --- /dev/null +++ b/source/libs/asura-lib-utils/threading/thread.h @@ -0,0 +1,60 @@ +#ifndef __ASURA_THREAD_H__ +#define __ASURA_THREAD_H__ + +#include +#include + +#include "thread_task.h" + +namespace AsuraEngine +{ + namespace Threading + { + + class ThreadImpl; + + /// + /// 线程主体,每个线程维护一个task queue。 + /// + class Thread ASURA_FINAL + : public AEScripting::Portable + { + public: + + LUAX_DECL_FACTORY(Thread); + + bool Enqueue(ThreadTask* task); + + void Run(); + + private: + + /// + /// 任务队列。 + /// + std::queue mTaskQueue; + + ThreadImpl* mImpl; + + LUAX_DECL_METHOD(_Enqueue); + LUAX_DECL_METHOD(_Run); + + }; + + /// + /// 线程的具体实现,对用户是透明的,一共准备了四种策略: + /// 1: win32 + /// 2: posix + /// 3: SDL + /// 4: std::thread + /// + ASURA_ABSTRACT class ThreadImpl + { + public: + + }; + + } +} + +#endif \ No newline at end of file -- cgit v1.1-26-g67d0