[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Coroutine trouble
- From: Alexander Gladysh <agladysh@...>
- Date: Sun, 15 Feb 2009 12:02:17 +0300
On Sat, Feb 14, 2009 at 10:56 PM, Alexander Gladysh <agladysh@gmail.com> wrote:
>>> local coro -- A forward declaration
>>> coro = coroutine.create(function()
>>> ENGINE.call_me_later(function() assert(coroutine.resume(coro)) end)
>>> coroutine.yield()
>>> end)
>>> assert(coroutine.resume(coro))
>>>
>>> When I run it, coroutine.resume() inside the callback fails with
>>> message "cannot resume running coroutine". Coroutine status is
>>> "running" and coroutine.running() points to the coroutine as well.
>>
>> It seems like ENGINE.call_me_later() is executing the function that it is
>> being passed before returning, so it gets run in the context of the coro
>> coroutine itself, which obviously cannot be resumed because it is not
>> suspended. I freely admit I may be misunderstanding something here though.
>
> No, I just double checked by adding extensive logging, callback gets
> called after whole main chunk is executed.
Actually I can not even imagine what may trigger such behaviour...
Does anyone have any advice on how to debug this?
This bug is with Lua Alchemy 0.2. It is filed here:
http://code.google.com/p/lua-alchemy/issues/detail?id=113
To reproduce it, paste the code from the issue into the Lua Alchemy demo:
http://lua-alchemy.googlecode.com/svn/trunk/demo/index.html
Unfortunately all callback error handling is going to Flash log, so
you have to be running under debug Flash. A workaround is to replace
print:
print = as3.makeprinter(output)
and replace asserts with code to print errors (also any as3.trace()
calls to calls to print()).
Any ideas are welcome!
Alexander.