lua-users home
lua-l archive

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


Since ref and the corresponding rawgeti are the fast methods for table access i use the following code to create myself a new co routine. 

lua_getfield(MainState, LUA_GLOBALSINDEX, "ThreadTable");
lua_State *thread = lua_newthread(MainState);
int refID = luaL_ref(MainState, -2);
lua_pop(MainState,1);

So now the when i want to let GC clean up the coroutine i need to :

lua_getfield(MainState, LUA_GLOBALSINDEX, "ThreadTable");
luaL_unref(MainState, -1, refID );

The remaining piece is where do i get refID when i want to unref? or how do I store that refID with the co routine?
Here are some of the possibilities/issues i have run into.
Thoughts about my specific issues?
Other suggestions/approaches that i haven't mentioned?

 Performance is a big concern to me with that in mind I'm curious how you guys would solve/layout something like this.

-Chris