lua-users home
lua-l archive

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


Also, i have some questions about the coroutines. because i will create and
dispose lots of coroutines, i have to implement a coroutines pool to
optimize this payload. it works fine when a coroutine ends normally, not
yielded, no errors. so I can recycle it into my pool. but when the coroutine
yields or errors, lua seemed saves the status and the stack of the
coroutine, and I didn't find a way to reset the coroutine to the initial
state, where I can put a new function to run. in this case, i have to
dispose the coroutine rather reuse in my pool. it still works fine now since
so far i don't need to terminate a yielding thread, but I guess this would
happen in some time... so I was wondering if there is a way to reset a
coroutine to the initial state, in 5.1 or any new functions will be
introduced to 5.2?

Why can not you simply allow those coroutines to be collected and create
new ones?


I guess my questions is :
Does the time it take to construct a coroutine state (in C) far exceed the time that it would take to re-initialize (the stack) of an existing coroutine that has thrown an error?

 DB