summaryrefslogtreecommitdiff
path: root/source/libs/asura-lib-utils/threading/thread.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-03-29 00:43:25 +0800
committerchai <chaifix@163.com>2019-03-29 00:43:25 +0800
commitf4c338c63f3456a8eccd56c35e233843687d55be (patch)
tree7278fe4723320c9ef310c5a04d92bf0be1bc778c /source/libs/asura-lib-utils/threading/thread.cpp
parent3bced067a4144381e59ce4bd0eb749eeff5ad1f4 (diff)
*thread
Diffstat (limited to 'source/libs/asura-lib-utils/threading/thread.cpp')
-rw-r--r--source/libs/asura-lib-utils/threading/thread.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/source/libs/asura-lib-utils/threading/thread.cpp b/source/libs/asura-lib-utils/threading/thread.cpp
index 51738de..9c71ace 100644
--- a/source/libs/asura-lib-utils/threading/thread.cpp
+++ b/source/libs/asura-lib-utils/threading/thread.cpp
@@ -13,9 +13,6 @@ namespace AsuraEngine
Thread::Thread(Luax::LuaxState& father, const std::string& name)
: mName(name)
{
- mState = lua_newthread(father);
- SetLuaxMemberRef(father, mStateRef, -1);
- lua_pop(father, 1); // mState
}
Thread::~Thread()
@@ -79,13 +76,18 @@ namespace AsuraEngine
return mName;
}
- void Thread::Execute()
+ void Thread::Process()
{
+ LUAX_STATE(AEScripting::LuaEnv::Get()->GetMainState());
while (!mTaskQueue.empty())
{
Task* task = mTaskQueue.front();
- if (task->Execute())
- task->Invoke(mState);
+ if (task && task->Execute())
+ {
+ // unsafe
+ task->Invoke();
+ this->LuaxRelease<Task>(state, task);
+ }
mMutex.Lock();
mTaskQueue.pop();