lua 讀寫檔案+非同步處理,複習一下
阿新 • • 發佈:2019-02-03
讀寫檔案+非同步處理,複習一下
--- --- Generated by EmmyLua(https://github.com/EmmyLua) --- Created by andrew. --- DateTime: 2018/3/12 13:53 --- local send = coroutine.create( function() local hint = "testSend:" local file = io.open("TestCoroutine.lua", "r") while true do local text = file:read() if nil == text then break end coroutine.yield(text) end file:close() end) print(coroutine.status(send)) for line = 1, 50 do local status, text = coroutine.resume(send) local s = coroutine.status(send) print(line, ", s = ", s, ", status = ", status, ", text = ", text) if not status then break end line = line + 1 end