lua-users home
lua-l archive

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


I have a situation where Lua wants to free a userdata, but I need the
userdata to stick around because separate obj-c code is still reliant
upon the userdata. My workaround was to add new luaT_eventname that
will return true if the obj-c code still needs the object (ie it's
retain count > 1) .

I do this check in the lgc.c traversetable method, which works great!
But the code requires a lua_State*, and the only way I can figure out
how to get one is through g->mainthread. You can check out the actual
code around line 195 here
http://github.com/probablycorey/wax/blob/master/lib/lua/lgc.c

Because I'm using the mainthread, I'm assuming I can't use coroutines
because they are run in different Lua threads. So is there a way I can
determine the currently running thread from inside the traversetable
method?

I am aware this is crazy, so no need to let me know that again. I'm
just wondering if anyone knows of an alternative solution, or if there
is a way to make the current solution work with coroutines.

Thanks,
Corey