[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Anchoring co-routines and properly dropping references to allow GC to clean them up
- From: Patrick Donnelly <batrick@...>
- Date: Tue, 6 Oct 2009 22:08:30 -0300
On Tue, Oct 6, 2009 at 9:48 PM, Chris Gagnon <firstname.lastname@example.org> 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);
> 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_rawseti(MainState, -2, refID);
lua_pop(MainState, 1); /* ThreadTable */
"Let all men know thee, but no man know thee thoroughly: Men freely
ford that see the shallows."
- Benjamin Franklin