[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: newproxy()
- From: Roberto Ierusalimschy <roberto@...>
- Date: Mon, 23 Nov 2009 10:55:08 -0200
> __gc is called asynchronously at rather unpredictable points in the
> program. A C extension writer can take that into account (and can
> actually do some useful work without invoking the garbage collector),
> but it's more difficult to do this in Lua code. It's also not
> possible to create a critical section which locks out the garbage
> collector.
>
> It might be better if there was some sort of __gcqueue metatable slot
> which referred to an array. When the object becomes unreachable, it
> is added to the __gcqueue array. Lua functions which interact with
> these objects would process the queue. This way, the side effect
> would occur at well-defined points in the program.
We thought about that. (Alexandra Barros, who did the first
implementation of ephemeron tables, also did a prototype implementation
of this feature.) One problem is memory allocation. What the collector
should do if there is a memory allocation error when resizing __gcqueue?
It is tricky to handle this situation.
-- Roberto