[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua State and callbacks from C
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 10 Oct 2012 11:38:02 -0300
> [...] I doubt, but have no certainty, that the
> GC will ever collect the currently active thread, even if not anchored.
> Maybe someone else can confirm this.
>
> Continuing the line of thought; if it could GC the active thread, then EVERY
> piece of C code MUST always have its first statement anchor the thread
> because it might be collected (which would be silly). So my logical
> conclusion is that my statement above must be right.
That is not true. The GC can collect the currently active thread if it
is not anchored. (The GC is incremental, so the notion of "currently" in
"currently active" is fuzzy.) The solution is not to anchor the thread
in every piece of C code, but to never call (run) a thread that is not
anchored. That is, every piece of C code assumes that, if a thread is
running, who called it made sure it was anchored.
-- Roberto