[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Different behavior for coroutines in Lua and LuaJIT + Recycling Coroutines
- From: Graham Wakefield <lists@...>
- Date: Mon, 16 Jun 2008 10:51:25 -0700
On Jun 15, 2008, at 1:47 PM, Mike Pall wrote:
Graham Wakefield wrote:
What I gathered from the list is that a coroutine that errors
recycled, but one that returns with no error can have its stack
be ready to be re-used. I just wondered if there was any more to
this; should I worry about any changes of environment, metatables
may have had side effects on the lua_State, and which would lead to
undefined behavior if recycled?
Yes, this is the current state of affairs. Recycling coroutines is
only feasible if you can control the complete execution (i.e. not
OK so I didn't miss anything!
Usually this would be a pool of coroutines handling a specific
task. Their outermost function runs a loop, fetching a work item
from a queue. A worker function is called and when it returns the
loop can continue without destroying the coroutine.
Unfortunately in my project, the end-user is expected to create and
destroy coroutines; they're an integral component of the user API. I
can't stop them from calling return!
Thanks for all your help, and looking forward to try luajit 2!