[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: releasing callback on GC
- From: Gaspard Bucher <gaspard@...>
- Date: Mon, 3 Jan 2011 03:01:19 +0100
Thanks, this seems to be the correct way to handle my issue. I am looking at lua_getfenv and lua_setfenv and am not sure if this is how it is meant to be used:
-- callback function is at 1
-- rk.Thread userdata is at 2
On Mon, Jan 3, 2011 at 2:03 AM, Peter Odding <email@example.com>
I'm not sure I have the full picture here, but why not give your thread userdata an environment table and then keep hold of the function in that environment table instead of in the global registry? Once your thread is garbage collected the environment table should be destroyed and any references in that table should automatically seize to exist.
This is a difficult one: I have an OS thread that keeps hold of a
function in lua with luaL_ref(L, LUA_REGISTRYINDEX). But the OS thread
is created in Lua:
thread = rk.Thread(function()
-- do this and that
After some time, the thread is garbage collected.
How can I remove the function from the registry ? I cannot call
luaL_unref in the rk.Thread destructor (segfault).
- Peter Odding