lua-users home
lua-l archive

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


Stefano Lanzavecchia wrote:
> 
> function hot_potato_1 ()
>         while (1) do
>                 print ("co1: n is ".. n)
>                 if (n <= 0) then
>                         return
> ...

Huh.  A coroutine that returns?  To where?

> ... and I did
> not have to change anything at all in the Lua source code.

I still think, that's impossible.

> To make sure the
> garbage collector does not collect stuff from suspended coroutines
> (including the one implicitly associated with main!) I have to copy on
> coronew the entire content of the stack into the new stack.

The stack is dynamic.  It will surely change after coronew.  So the
snapshot copied will not be valid very long.  And, the stacks of _all_
coroutines have to be marked by the gc.  Not only that of the current
coroutine and a snapshot of it's creator's stack.

Ciao, ET.