[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: LuaJIT and keeping objects alive
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 25 Nov 2009 18:04:48 -0200
> The context it came up in was a module providing a try/finally
> mechanism. I was guided by earlier discussion on this list, and
> especially the techniques used in:
> For the usual cases---that is, successful completion of the protected
> block, and ALSO errors raised during the execution of the protected
> block---then my wrapper functions will explicitly take care of
> running all the finalizers that have been registered.
> But you made the point in an earlier thread that if protected blocks
> were allowed to yield, their thread might eventually end up being gc'd
> instead of resuming. So you said a fully general exception-handling
> mechanism had to make use of the __gc mechanism.
I think my suggestion (which was actually from someone else) was for
resource cleanup, which is not the same as exception handling. But
I may be wrong (now and/or earlier ;)
Anyway, currently I do not think it is wise to assume that an object
will not be finalized if it not going to be used.