lua-users home
lua-l archive

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


On Tue, Oct 6, 2009 at 9:48 PM, Chris Gagnon <cgagnon@zindagigames.com> wrote:
> Apologizes for the partial email, what a way to introduce myself ;o)
>
> Lets assume we have a MainState, and a "ThreadTable" in the global table
>
> lua_getfield(MainState, LUA_GLOBALSINDEX, "ThreadTable");
> lua_State *thread = lua_newthread(MainState);
> int refID = luaL_ref(MainState, -2);
> lua_pop(MainState,1);
[...]
> The problem i'm running into is how do I remove my reference/anchor, when
> the coroutine is simply done.

Sorry if I misunderstand, but isn't this all you want?

lua_getfield(MainState, LUA_GLOBALSINDEX, "ThreadTable");
lua_pushnil(MainState);
lua_rawseti(MainState, -2, refID);
lua_pop(MainState, 1); /* ThreadTable */

-- 
-Patrick Donnelly

"Let all men know thee, but no man know thee thoroughly: Men freely
ford that see the shallows."

- Benjamin Franklin