开源软件名称(OpenSource Name):xopxe/lumen开源软件地址(OpenSource Url):https://github.com/xopxe/lumen开源编程语言(OpenSource Language):Lua 98.3%开源软件介绍(OpenSource Introduction):Lumen: Lua Multitasking Environment."A nice generic framework to develop complex, portable concurrent applications in Lua." IntroductionLumen is a very simple environment for coroutine based multitasking. Consists of a scheduler, and that's it. The API was inspired by a brief description of Sierra's scheduler. Lumen has no external dependencies nor C code, and runs on unmodified Lua (works with Lua 5.1, 5.2 and LuaJIT). Tasks that interface with LuaSocket and nixio for socket and async file I/O support are provided. Lumen's API reference is available in the How does it look?Here is a small program, with two tasks: one emits ten numbered signals, one second apart. Another tasks receives those signals and prints them. local sched=require 'lumen.sched'
-- task receives signals
sched.run(function()
local waitd = {'an_event'}
while true do
local _, data = sched.wait(waitd)
print(data)
end
end)
-- task emits signals
sched.run(function()
for i = 1, 10 do
sched.signal('an_event', i)
sched.sleep(1)
end
end)
sched.loop() TasksTasks can emit signals, and block waiting for them, and that's it.
Pipes & StreamsThere are also pipes and streams, for intertask communications.
MutexesThere are cases when you must guarantee that only one task is accessing a piece of code at a time. Mutexes provide a mechanism for that. Notice that Lumen, being a cooperative scheduler, will never preempt control from a task. That means you only may have to resort to mutexes when your critical piece of code relinquish control explicitly, for example with a call to sleep, emitting a signal or blocking waiting for a signal. GoodiesThere are a few other useful modules, like an integrated remote Lua shell and a lightweigth HTTP server. How to try it out?There several test programs in the tests/ folder. This example has a few tasks exchanging messages, showing off basic functionality:
LicenseSame as Lua, see COPYRIGHT. Who?Copyright (C) 2012 Jorge Visca, jvisca@fing.edu.uy ContributorsAndrew Starks (@andrewstarks) |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论