lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



On 20-Aug-05, at 7:00 PM, Brent Arias wrote:

To stop a lua coroutine, the documentation only mentions yield() ... or the return from the main coroutine function. But I would like the ability to externally stop or terminate a coroutine. 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?

Most likely I will attempt this "kill" from C++ rather than from within Lua.
But knowing how to address this from lua or C++ would be helpful.

When the last reference to the thread (coroutine) disappears, the garbage collector will take care of it.

By the way, threads are left in a graceful state by yield. (Almost) nothing needs to be done to them aside from freeing the storage they occupy (their stack and their callinfo stack).