MCPcopy Create free account
hub / github.com/Tencent/UnLua / ResumeThread

Method ResumeThread

Plugins/UnLua/Source/UnLua/Private/LuaEnv.cpp:414–439  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

412 }
413
414 void FLuaEnv::ResumeThread(int32 ThreadRef)
415 {
416 lua_State** ThreadPtr = RefToThread.Find(ThreadRef);
417 if (!ThreadPtr)
418 return;
419
420 lua_State* Thread = *ThreadPtr;
421#if 504 == LUA_VERSION_NUM
422 int NResults = 0;
423 int32 Status = lua_resume(Thread, L, 0, &NResults);
424#else
425 int32 Status = lua_resume(Thread, L, 0);
426#endif
427 if (Status == LUA_YIELD)
428 return;
429
430 if (Status != LUA_OK)
431 {
432 const auto ErrMsg = lua_tostring(Thread, -1);
433 UE_LOG(LogUnLua, Error, TEXT("%s"), UTF8_TO_TCHAR(ErrMsg));
434 }
435
436 ThreadToRef.Remove(Thread);
437 RefToThread.Remove(ThreadRef);
438 luaL_unref(L, LUA_REGISTRYINDEX, ThreadRef); // remove the reference if the coroutine finishes its execution
439 }
440
441 UUnLuaManager* FLuaEnv::GetManager()
442 {

Callers 2

OnLegacyCallbackMethod · 0.80

Calls 4

lua_resumeFunction · 0.85
luaL_unrefFunction · 0.85
FindMethod · 0.45
RemoveMethod · 0.45

Tested by

no test coverage detected