CoRoutine is lua coroutine manager, that makes work with coroutines a little easier.
First, we create a new coroutine.
local lib = require "CoRoutine"
local coro = lib.create(function()
for i=1, 10 do
print(i)
coroutine.yield()
end
end, true)
--[[
Explain, this code will create a new coroutine, and resume it after creating.
CoRoutine.create(function, resume, resume_args);
]]
Now we can get it status:
print(lib.status(coro))
And resume it again!
print(lib.resume(coro))
Just creates a new coroutine and resumes if true.
local lib = require "CoRoutine"
lcoal coro = lib.create(function(a) print(a) end, true, 256)
Returns status of CoRoutine object.
print(lib.status(coro))
Returns resume result of CoRoutine object.
print(lib.resume(coro, {1})