[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua registry, environment, and threads.
- From: Doug Currie <doug.currie@...>
- Date: Wed, 6 Jan 2010 15:29:43 -0500
On Jan 6, 2010, at 1:50 PM, Leo Razoumov wrote:
> On 2010-01-06, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
>>
>> In C, it is not difficult to use the thread itself as a key to store
>> per-thread data in the registry, if necessary.
>
> How would it play with GC? Do I need to manually remove the key from
> the registry to let gc collect a dead thread?
The usual way to deal with this is for your library to put a new table in the registry that is weak-keyed, and put your per-thread data in this table keyed by the thread. The extra level of indirection costs a bit, of course.
e
- References:
- Lua registry, environment, and threads., Christian Tellefsen
- Re: Lua registry, environment, and threads., Patrick Donnelly
- Re: Lua registry, environment, and threads., Roberto Ierusalimschy
- Re: Lua registry, environment, and threads., Christian Tellefsen
- Re: Lua registry, environment, and threads., Roberto Ierusalimschy
- Re: Lua registry, environment, and threads., Leo Razoumov