[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: How to terminate lua script correctly?
- From: Булычев Михаил <mbul@...>
- Date: Wed, 26 Sep 2012 14:11:22 +0700
Suppose we have the following code:
DWORD WINAPI MainCodeThread(LPVOID param)
{
LuaScript *script=(LuaScript*)param;
lua_State *main = script->MainCode();
//test
//
lua_getfield (main, LUA_GLOBALSINDEX, "main");
script->SetState(STATE_STARTED);
int lua_err = lua_pcall(main, 0, 0, 0);
if (lua_err)
{
sprintf(script->LastError(), "%s", lua_tostring(main, -1));
lua_pop(main, 1);
script->SetState(STATE_STOPPED);
return lua_err;
}
script->SetState(STATE_STOPPED);
return 0;
...
HANDLE mainCodeThread = CreateThread(NULL, 0, MainCodeThread, this, 0,
NULL);
...
how to terminate thread and close lua VM correctly?
Use lua_error() leads us to exception.
--
С уважением,
Булычев Михаил
E-Mail: mbul@arqa.ru
ICQ: 12755561