[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How to stop yielded threads from being garbage collected
- From: Peter Pimley <peter.pimley@...>
- Date: Thu, 24 Nov 2011 10:57:48 +0000
On 24 November 2011 10:05, Martin Linklater <mslinklater@gmail.com> wrote:
> Thanks for that Peter - it now breaks instantly 8).
:)
So now, as HyperHacker says, you need to store a reference to the
thread somewhere in Lua. It sounds like you ought to have a table
containing all your active threads. That table itself will need to be
stored somewhere, either as a member of another table, or a global, or
in the registry. I don't know what you're creating, but it sounds
like the registry would be the best place to put it. See
http://www.lua.org/pil/27.3.2.html . In C, do something like:
// with the active threads table on the top of the stack...
int active_thread_table = luaL_ref (lua, LUA_REGISTRYINDEX);
// and then later, when you want to iterate over that table...
lua_gettable (lua, active_thread_table);
// active thread table is now on top of the stack.
(Sorry if any of that is obvious.)