[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Coroutine trouble
- From: Alexander Gladysh <agladysh@...>
- Date: Sat, 14 Feb 2009 22:56:34 +0300
>> 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.
Alexander.