在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):cloudwu/hive开源软件地址(OpenSource Url):https://github.com/cloudwu/hive开源编程语言(OpenSource Language):C 79.0%开源软件介绍(OpenSource Introduction):HiveParallel multiple lua states , actor model for lua. Quick Startmake and run
the main logic is in test/main.lua . You can read this blog first (http://blog.codingnow.com/2013/06/hive_lua_actor_model.html) (In Chinese) How to Launch the hivelocal hive = require "hive"
hive.start {
thread = 4, -- 4 worker thread, You can set more if you have more cpu core.
main = "test.main", -- main cell, the cell name search rule is the same with require.
} How the cell workLet's read test/pingpong.lua first. local cell = require "cell"
cell.command {
ping = function()
cell.sleep(1)
return "pong"
end
}
function cell.main(...)
print("pingpong launched")
return ...
end If you launch test.pingping, the function cell.main(...) will be execute first. You can use cell.cmd("launch", "test.pingpong", ...) to launch it. test.pingpong is a simple cell that support one command 'ping'. If you send a command 'ping' to it, It will sleep 0.01 second first, and the send 'pong' back. None-blocking socket libraryHive support none-blocking socket api that can be used in every cell. cell.listen can be used in a server cell, the accepter will be call every time accept a new connection. You can forward the data from new connection to a new cell, or forward to itself (fork a coroutine to deliver the data). cell.connect can be used in a client cell. Todo
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论