1
0
mirror of https://github.com/kepler155c/opus synced 2025-10-18 17:27:39 +00:00

new icon set + scanning miner

This commit is contained in:
kepler155c@gmail.com
2018-10-15 16:05:43 -04:00
parent ecb3af4672
commit 8b50127f21
5 changed files with 49 additions and 14 deletions

View File

@@ -136,6 +136,18 @@ function Event.waitForEvent(event, timeout)
until e[1] == 'timer' and e[2] == timerId
end
-- Set a handler for the terminate event. Within the function, return
-- true or false to indicate whether the event should be propagated to
-- all sub-threads
function Event.onTerminate(fn)
Event.termFn = fn
end
function Event.termFn()
Event.terminate = true
return true -- propagate
end
function Event.addRoutine(fn)
local r = setmetatable({
co = coroutine.create(fn),
@@ -204,11 +216,16 @@ end
function Event.pullEvent(eventType)
while true do
local e = { os.pullEventRaw() }
local propagate = true -- don't like this...
Event.terminate = Event.terminate or e[1] == 'terminate'
if e[1] == 'terminate' then
propagate = Event.termFn()
end
processHandlers(e[1])
processRoutines(table.unpack(e))
if propagate then
processHandlers(e[1])
processRoutines(table.unpack(e))
end
if Event.terminate then
return { 'terminate' }

View File

@@ -653,7 +653,6 @@ function Util.getOptions(options, args, ignoreInvalid)
end
end
return true, Util.size(rawOptions)
end
return Util