Skip to content

CoRoutine is lua coroutine manager, that makes work with coroutines a little easier.

License

Notifications You must be signed in to change notification settings

4x4x8/CoRoutine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

CoRoutine

CoRoutine is lua coroutine manager, that makes work with coroutines a little easier.

How to use

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))

API

CoRoutine.create(function, resume, resume_args)

Just creates a new coroutine and resumes if true.

local lib = require "CoRoutine"
lcoal coro = lib.create(function(a) print(a) end, true, 256)

CoRoutine.status(CoRoutine)

Returns status of CoRoutine object.

print(lib.status(coro))

CoRoutine.resume(CoRoutine, args)

Returns resume result of CoRoutine object.

print(lib.resume(coro, {1})

About

CoRoutine is lua coroutine manager, that makes work with coroutines a little easier.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages