[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: lua_newthread(), good way to keep the thread values?
- From: Carsten Fuchs <CarstenFuchs@...>
- Date: Thu, 23 Aug 2007 10:55:35 +0200
many thanks for your answer!
Vijay Aswadhati wrote:
On Wednesday, August 22, 2007 9:45 AM, Carsten Fuchs wrote:
Well... I was wondering how to best solve the problem. (And if
my assumption above that the thread is never collected is
If my understanding of Lua is right then I think what you should be
reading about is 'weak table'.
I did, but...
"A weak table can have weak keys, weak values, or both. A table with
weak keys allows the collection of its keys,
but prevents the collection of its values. A table with both weak
keys and weak values allows the collection of
both keys and values. In any case, if either the key or the value is
collected, the whole pair is removed from the
... if I understood the last statement correctly, I think that there still is a problem:
If I have TableInRegistry have weak keys (but normal, i.e. non-weak, values), the key-value pairs
can be collected ahead of time, because there are no other references to the keys (which are the
"thread" objects that I want to anchor in the first place).
Thinking about it, I'll probably switch to the approach that stores unique Thread-ID numbers as the
keys and the thread objects as the values in TableInRegistry, because that solves my original
question and solves another problem with not being able to insert new elements into a table while
iterating over it using lua_next().
Ca3D - Engine http://www.Ca3D-Engine.de
Carsten Fuchs http://www.Ca3D-Engine.de/c_Carsten.php