lua-users home
lua-l archive

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


Hi.

Is it safe/correct to use lua_call on a yielded coroutine? And is it
safe/correct to yield from the main lua state?

The situation is this: I'm running a C program that calls a lua script
from main() and exits, which usually looks like this:

--
local loop = Loop:new()
local result = loop:run()
loop:cleanup()

return result
--

"Loop" is a c++ class that goes into the main loop and calls into lua
to deliver events, etc. The problem is that I'm porting to a platform
that takes over the main loop, and I can't implement my own.

So I'm thinking I can use lua_resume to start the script, make the
"run" method yield, and then go into the platform's loop, which would
deliver events to lua (using lua_call on the yielded state).
Eventually when the program shuts down, I use lua_resume and exit.

So far it looks like it works, but it seems like using lua_call would
mess up the whole thing.. Is this doable?

Thanks..

Ariel.