[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: thread state and dynamically loadable library
- From: Edgar Toernig <froese@...>
- Date: Tue, 5 Sep 2006 20:29:39 +0200
Doug Currie wrote:
>
> An approach that might work is to create a per-thread table for thread
> local storage and put it in the registry keyed on the thread's
> identity (i.e., L). This would work until some other library tried to
> put something else in the registry keyed on L. I could construct a
> "more unique key" such as L concatenated with the address of some
> object in my library, but this either runs the risk of running out of
> bits in LUA_NUMBER, or taking lots of time in re-constructing the key
> every time the context is needed.
Module private registries are easy:
#define MY_REGISTRY lua_upvalueindex(1)
and then make sure that you put the registry table into the first
upvalue of each function of your module.
Ciao, ET.