lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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