Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

510 Commits

Repository files navigation

ltask: Yet another lua task library

ltask is inspired by skynet (https://github.com/cloudwu/skynet) , but it's a library rather than a framework.

It implement an n:m scheduler , so that you can run M lua VMs on N OS threads.

Each lua service (an independent lua VM) works in request/response mode, they use message channels to inter-communicate.

root is a special service that can spawn new services. For example,

-- userlocalltask=require"ltask"localS= {}
print"User Start"functionS.ping(...)
ltask.timeout(10, function() print(1) end)
ltask.timeout(20, function() print(2) end)
ltask.timeout(30, function() print(3) end)
ltask.sleep(40) -- sleep 0.4 sec-- responsereturn"PING", ...endreturnS
-- rootlocalfunctionboot()
print"Root Start"print(os.date("%c", (ltask.now())))
localaddr=S.spawn("user", "Hello")	-- spawn a new service `user`print(ltask.call(addr, "ping", "PONG"))	-- request "ping" messageendboot()

Test

lua test.lua

About

Yet another lua task library, n:m scheduler

Resources

Stars

326 stars

Watchers

19 watching

Forks

Used by

Contributors

Languages