[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: kill coroutine
- From: "Brent Arias" <barias@...>
- Date: Sat, 20 Aug 2005 20:50:30 -0700
I'm not sure, but I think what Rici is saying is this: if coroutine "A" has
yielded, and then the main "thread" (from lua or just an access from C++)
sets the only coroutine reference "A" to nil, then **yes** the coroutine
will gracefully be cleaned up by Lua (even though it had not terminated).
And in answer to David's concern about an "implicit reference", I think Rici
is saying that there is no implicit reference to worry about. I think Rici
is saying, just set the coroutine to nil, and the "yielded" coroutine will
be destroyed and cleaned-up (even though it never terminated).
Is all this correct?
By the way, I am not using a muti-threaded environment - I am not using
system threads. So when I speak of the main "thread", its just a manner of
speaking (I don't know what else to call it).
[mailto:firstname.lastname@example.org]On Behalf Of Rici Lake
Sent: Saturday, August 20, 2005 5:41 PM
To: Lua list
Subject: Re: kill coroutine
On 20-Aug-05, at 7:19 PM, David Given wrote:
> I am curious to know what happens if a coroutine nils out its own last
> reference, though. Does the program counter carry an implicit
> reference to
> the code its executing? What happens when the coroutine yields?
The currently running thread (and therefore its stack) are always part
of the gc root. So is the "main thread" (and its stack).
If there is no reference left to a coroutine and the coroutine yields,
then it will get garbage collected at some point.