
协程
一扇小桃红
自由的代价是永远的警惕。
展开
-
【lua学习】协程 元表 处理多个生产者与消费者的问题 应用skynet消息传递
【lua学习】协程 元表 处理多个生产者与消费者的问题之前写了队列queue的类,现在想处理多个生产者与消费者的问题协程类封装起来,-- coroutines.luacoroutines = {}local function sleep(n) os.execute("sleep "..n) endfunction coroutines:doProducter(id...原创 2019-11-09 15:00:11 · 250 阅读 · 0 评论 -
【lua学习】 闭包和协程使用
【lua学习】 闭包和协程使用自己随便写的案例-- coroutine_closures.luafunction indexFun() local x = 3 return function() x = x - 1 return x end endfunction funYield(t) print("fun") ...原创 2019-11-09 14:30:00 · 216 阅读 · 0 评论 -
【Lua】Coroutine 协程和闭包学习
Coroutine 协程学习一、status:supended、running、dead二、方法:coroutine.resume() 唤醒:1、正常退出,coroutine.resume返回true2、异常发生错误,coroutine.resume返回falsecoroutine.yield() 挂起:但yield在协程被挂起时可以返回值,而return只有协程结束才能有返回...原创 2019-11-05 20:27:56 · 525 阅读 · 0 评论