[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: void* in Lua_State for Application?
- From: Tim Hill <drtimhill@...>
- Date: Sun, 1 Sep 2013 09:36:40 -0700
On Sep 1, 2013, at 12:52 AM, Thijs Schreijer <thijs@thijsschreijer.nl> wrote:
>
>
> Not an answer to your question, merely a remark on states. Depending on whether you need the pointer to a State or to a thread/coroutine inside a state your solutions may not work properly. The lua_State you get could point to a coroutine, which might die anytime after you've stored it.
> On 5.2 you might use the LUA_RIDX_MAINTHREAD [1] index to get the mainthread for the state. But that will also cost you one registry table lookup.
>
> Thijs
>
> [1] http://www.lua.org/manual/5.2/manual.html#4.5
>
Very good point, and one I'd not fully considered. I wonder about the "custom allocator" trick; it would seem to me that additional coroutine Lua states should all share the same allocator, in which case lua_getallocf() should always work regardless of the Lua_State passed to the C function; I've not had time to test this yet; the docs are silent on this.
--Tim