lua-users home
lua-l archive

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


In wxLua, but I think this is general, if someone creates a coroutine
and within that coroutine creates a local table/function/userdata that
wxLua must ref in the registry (for a callback for example), is that
valid? I see that the global table as well as the registry is shared
between the main and coroutine states, but what about refs to locals?

Secondly, I am having trouble wrapping my head around what exactly
must be dealt with when a coroutine state is closed. From our point of
view, the program starts with one lua_State and all C++ callbacks take
a C++ class that uses reference counting so that if the lua_State is
closed the program won't crash. However, when a coroutine is created,
all of a sudden a new lua_State appears and this is the one we pull
and push objects from/into and just as it appeared as though from
nowhere it disappears and any callbacks call an invalid lua_State. How
can this best be handled without modifying Lua. I would like to keep
wxLua usable as a loadable module.

On one hand, perhaps it is as simple as not allowing any C++ callbacks
to be created from within a coroutine since this means that the C++
callback may try to run a function it refed in the registry in a
suspended or worse yet, a dead callback. Both of these are not
allowed, right?

Regards,
    John