lua-users home
lua-l archive

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


Hi,

Brent Arias wrote:
> I keep creating new coroutines with lua_newthread, and each time I do, I
> notice lua_gettop is incrementing by one.  Am I supposed to be immediately
> popping them from the stack when I create them? Or am I supposed to leave
> them there (until their life is over)?

You can either leave them on the stack (if you only have
a fixed number of them) or you can store them in a table
(if you have lots of them).

Popping them but still using them afterwards will screw up
the garbage collector.

> Why does lua assume to automatically put new threads I create onto the stack
> for me?

http://lua-users.org/lists/lua-l/2005-08/msg00333.html

Bye,
     Mike