lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I have a question about detecting completed threads. Say you have the 
following code:

new_thread = lua_newthread(L);
lua_getglobal(new_thread, "some_function");
lua_cobegin(new_thread, 0);
lua_resume(L, new_thread);

Say the Lua function, some_function(), yields a variable number of 
times while executing. You need to call lua_resume() several times on 
the new thread to continue execution each time. However, if execution 
of some_function() is completed and you call lua_resume() on the 
thread, bad things happen. The function, lua_closethread(), should be 
called on the thread instead of lua_resume().

My question is, is there a way to detect if a thread has completed 
execution?