lua-users home
lua-l archive

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

2009/3/29 lee <>:
> Ok, it looks direct.
> To me, the difference between running and normal is obscure.
> What "normal" means ?
A coroutine's status is normal when it has been resumed, but has
itself resumed another, so it isn't the most directly active one. It's
running, but it's not the result of coroutine.running().


local sub_cr =
                       print("in sub-coroutine")
                       print(" -- sub_coroutine status: "
                             .. coroutine.status(coroutine.running()))
                       print(" -- caller status: "
                             .. coroutine.status(caller))
local caller_cr =
                       print("in caller coroutine, about to resume
                       coroutine.resume(to_call, coroutine.running())
                       print("back in caller")
                       print(" -- caller status: "
                             .. coroutine.status(coroutine.running()))

coroutine.resume(caller_cr, sub_cr)

===== yields =====

> dofile("/tmp/lua-268182el")
in caller coroutine, about to resume sub_coroutine
in sub-coroutine
 -- sub_coroutine status: running
 -- caller status: normal
back in caller
 -- caller status: running

Hope that helps,
Scott Vokes