-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
48 lines (39 loc) · 924 Bytes
/
main.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
local config = require("config")
local global_control = require("global_control")
local Reactor = require("reactor")
local ui = require("ui")
local thread = require("thread")
local event = require("event")
local reactors = {}
local threads = {}
local function reactors_setup()
for i, cfg in ipairs(config.reactors) do
reactors[i] = Reactor:new(cfg)
end
end
local function reactors_start()
for i, reactor in ipairs(reactors) do
threads[i] = thread.create(reactor.run, reactor)
end
end
local function reactors_running()
local all_finish = true
for i, t in ipairs(threads) do
if t:status() ~= "dead" then
all_finish = false
break
end
end
return not all_finish
end
local function ui_loop()
ui.setup(reactors)
ui.loop(reactors_running)
end
local function start()
global_control.setup(config.global_controls)
reactors_setup()
reactors_start()
ui_loop()
end
start()