This repository has been archived by the owner on Sep 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.lua
73 lines (73 loc) · 1.6 KB
/
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
local _runtimes = {
{
"snihook/dev",
true
},
{
"snihook/hook",
false
}
}
local runtime, runtimes
do
local _obj_0 = require("rcu") and require("lunatik")
runtime, runtimes = _obj_0.runtime, _obj_0.runtimes
end
local run, shouldstop
do
local _obj_0 = require("thread")
run, shouldstop = _obj_0.run, _obj_0.shouldstop
end
local inbox
inbox = require("mailbox").inbox
local schedule, time
do
local _obj_0 = require("linux")
schedule, time = _obj_0.schedule, _obj_0.time
end
return function()
local dev_hook = inbox(100 * 1024)
local log = inbox(100 * 1024)
runtimes = runtimes()
for _index_0 = 1, #_runtimes do
local r = _runtimes[_index_0]
local path, sleep
path, sleep = r[1], r[2]
assert(not runtimes[path], "Please stop " .. tostring(path) .. " before launching this script.")
local rt = runtime(path, sleep)
run(rt, path, dev_hook.queue, log.queue)
r[3] = rt
runtimes[path] = rt
end
local previous = {
__mode = "kv"
}
while not shouldstop() do
do
local event = log:receive()
if event then
local t = time() / 1000000000
do
local _t = previous[event]
if _t then
if t - _t >= 10 then
previous[event] = nil
end
else
print(event)
previous[event] = t
end
end
else
schedule(1000)
end
end
end
for _index_0 = 1, #_runtimes do
local _des_0 = _runtimes[_index_0]
local path, _, rt
path, _, rt = _des_0[1], _des_0[2], _des_0[3]
rt:stop()
runtimes[path] = nil
end
end