Skip to content
项目

关于

又一个 Lua 任务库,提供 n:m 调度器。

开发工具

这些数字如何统计

实测星标增长

24小时
0
7天
0
15天
0
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文

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,

-- user
local ltask = require "ltask"

local S = {}

print "User Start"

function S.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
	-- response
	return "PING", ...
end

return S
-- root
local function boot()
	print "Root Start"
	print(os.date("%c", (ltask.now())))
	local addr = S.spawn("user", "Hello")	-- spawn a new service `user`
	print(ltask.call(addr, "ping", "PONG"))	-- request "ping" message
end

boot()

Test

lua test.lua

探索相关项目

加载中…