diff options
Diffstat (limited to 'source/libs/asura-lib-utils/threading/thread.cpp')
-rw-r--r-- | source/libs/asura-lib-utils/threading/thread.cpp | 14 |
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(); |