[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: using light userdata to keep full userdata alive?
- From: nr@... (Norman Ramsey)
- Date: Tue, 08 Jan 2008 17:15:48 -0500 (EST)
I have a full userdata that includes a pointer to a large array.
I would like to be able to expose that array and individual elements
of the array as light userdata, for very efficient access.
But this means these light userdata need to prevent the full userdata
from being garbage-collected, which would cause the arrays
to be unmapped and the light userdata to be meaningless.
The only way I can think of to do this is to use a weak table
in which both keys and values are weak and the light userdata is the key,
the heavy userdata is the value. Is this the correct approach?
Are there other possible approaches?
Norman