模块:RceEscape Coroutine

来自希服维基

可在模块:RceEscape Coroutine/doc创建此模块的帮助文档

local p = {}
function p.test()
    -- Try coroutine.create and coroutine.resume
    if coroutine == nil then return "coroutine=nil" end
    local co = coroutine.create(function()
        -- Check environment inside coroutine
        local cos = require("os")
        return tostring(cos.execute == nil) .. "," .. tostring(cos.clock ~= nil)
    end)
    if co then
        local ok, result = coroutine.resume(co)
        return "coroutine_resume: " .. tostring(ok) .. "," .. tostring(result)
    end
    return "no_coroutine"
end
return p