[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: kill coroutine
- From: David Given <dg@...>
- Date: Sun, 21 Aug 2005 01:19:53 +0100
On Sunday 21 August 2005 01:00, Brent Arias wrote:
> For example, if I simply set the
> coroutine variable to nil, will Lua understand to kill the coroutine
> (regardless if it is yielded or not) and clean up its stack, all in a
> graceful fashion?
I would have thought so. Once the last reference to the coroutine is lost, the
entire thing will be garbage collected; code, stack, locals, the lot.
Incidentally, you can *only* do this, with someone else's coroutine if you're
running --- if it hasn't yielded, then *it* must be running! Remember that
coroutines aren't threads.
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?
"Curses! Foiled by the chilled dairy treats of righteousness!" --- Earthworm
Description: PGP signature