lua_resumeint lua_resume (lua_State *L, int narg);
Starts and resumes a coroutine in a given thread.
To start a coroutine, you first create a new thread
(see lua_newthread);
then you push onto its stack the main function plus any arguments;
then you call lua_resume,
with narg being the number of arguments.
This call returns when the coroutine suspends or finishes its execution.
When it returns, the stack contains all values passed to lua_yield,
or all values returned by the body function.
lua_resume returns
LUA_YIELD if the coroutine yields,
0 if the coroutine finishes its execution
without errors,
or an error code in case of errors (see lua_pcall).
In case of errors,
the stack is not unwound,
so you can use the debug API over it.
The error message is on the top of the stack.
To restart a coroutine, you put on its stack only the values to
be passed as results from yield,
and then call lua_resume.