[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LuaJIT and keeping objects alive
- From: Jim Pryor <lists+lua@...>
- Date: Wed, 25 Nov 2009 15:38:58 -0500
On Wed, Nov 25, 2009 at 06:04:48PM -0200, Roberto Ierusalimschy wrote:
> > 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 ;)
You're right. I was imprecise because I'm thinking about mechanisms that
take care of both. At the moment, though, we are as you say talking about
finalization/cleanup.
> 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.
Thanks.
What I'm now doing instead, as I said, is keeping the userdatum (whose
job it is to cleanup when the thread is gc'd) alive in a different
way.
This is the most natural way to run finalization code when a thread gets
collected, isn't it? To create a userdatum with a __gc that stays
alive as long as the thread does?
--
Profjim
profjim@jimpryor.net