diff options
Diffstat (limited to 'source/modules/asura-utils/threading/thread.h')
-rw-r--r-- | source/modules/asura-utils/threading/thread.h | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/source/modules/asura-utils/threading/thread.h b/source/modules/asura-utils/threading/thread.h index 340fca3..d365fd0 100644 --- a/source/modules/asura-utils/threading/thread.h +++ b/source/modules/asura-utils/threading/thread.h @@ -9,6 +9,7 @@ #include "task.h" #include "mutex.h" #include "semaphore.h" +#include "threadable.h" namespace AsuraEngine { @@ -19,7 +20,7 @@ namespace AsuraEngine /// /// ̵߳ļֲͬʵ֣ - /// 1: Deferredӳģʽ߳ϵɺҪ̵ֶ߳Post + /// 1: Deferredӳģʽ߳ϵɺҪ̵ֶ߳Dispatch /// ̵߳ص첽Ϊͬlua_Stateͻ⡣ /// 2: Immediateģʽÿһ߳άһlua_newthreadlua_State /// صڲͬlua_Stateеãⲻ̷ͬ߳ͬһlua_State @@ -27,7 +28,7 @@ namespace AsuraEngine enum ThreadType { THREAD_TYPE_DEFERRED, - THREAD_TYPE_IMMEDIATE, + THREAD_TYPE_IMMEDIATE, // unsafe }; enum ThreadState @@ -43,6 +44,7 @@ namespace AsuraEngine /// class Thread ASURA_FINAL : public AEScripting::Portable<Thread> + , public Threadable { public: @@ -102,14 +104,14 @@ namespace AsuraEngine /// /// ִС /// - void Process(); + int Process() override; const std::string& GetName(); /// /// ص /// - void Post(); + void Dispatch(); /// /// ߺ @@ -141,7 +143,7 @@ namespace AsuraEngine LUAX_DECL_METHOD(_IsStopped); LUAX_DECL_METHOD(_IsCurrent); LUAX_DECL_METHOD(_Sleep); - LUAX_DECL_METHOD(_Post); + LUAX_DECL_METHOD(_Dispatch); LUAX_DECL_METHOD(_GetName); LUAX_DECL_METHOD(_GetType); LUAX_DECL_METHOD(_GetState); @@ -149,14 +151,15 @@ namespace AsuraEngine //----------------------------------------------------------------------------// + ThreadImpl* mImpl; + + lua_State* mLuaThread; + /// /// ˴Ƿػģʽ /// bool mIsDaemon; - lua_State* mLuaThread; - - ThreadImpl* mImpl; std::string mName; ThreadType mType; uint mSleepTime; @@ -204,7 +207,7 @@ namespace AsuraEngine ThreadImpl() {}; virtual ~ThreadImpl() {}; - virtual bool Start(Thread* thread, uint32 stacksize = 0) = 0; + virtual bool Start(Threadable* thread, uint32 stacksize = 0) = 0; virtual void Join() = 0; virtual void Kill() = 0; |