模块 coroutine

require "coroutine"

公开 API

API实现说明
coroutine.createsoupB_cocreate创建新协程:返回协程对象,参数 f 为其主函数
coroutine.resumesoupB_coresume恢复/启动协程 co;首次调用时传入参数给主函数,返回 true+返回值
coroutine.runningsoupB_corunning返回当前运行的协程(主协程返回 nil)及其是否为主协程
coroutine.statussoupB_costatus返回协程状态:'suspended'/'running'/'normal'/'dead'
coroutine.wrapsoupB_cowrap创建协程并返回包装函数,调用时自动 resume
coroutine.yieldsoupB_yield挂起当前协程,将参数传给 resume 的返回值;可继续被唤醒
coroutine.isyieldablesoupB_yieldable检查当前协程是否可 yield
coroutine.closesoupB_close关闭协程:若在挂起态则使其恢复并关闭(可触发 __close)
← 返回模块索引