mirror of
https://github.com/kepler155c/opus
synced 2025-01-17 10:52:53 +00:00
trigger event instead of os.queueEvent
This commit is contained in:
parent
66f9481e7d
commit
496e95a6c4
@ -243,6 +243,21 @@ local function processRoutines(...)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- invoke the handlers registered for this event
|
||||||
|
function Event.trigger(event, ...)
|
||||||
|
local handlers = Event.types[event]
|
||||||
|
if handlers then
|
||||||
|
for _,h in pairs(handlers) do
|
||||||
|
if not h.co then
|
||||||
|
-- callbacks are single threaded (only 1 co per handler)
|
||||||
|
h.co = createCoroutine(h)
|
||||||
|
Event.routines[h.uid] = h
|
||||||
|
h:resume(event, ...)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function Event.processEvent(e)
|
function Event.processEvent(e)
|
||||||
processHandlers(e[1])
|
processHandlers(e[1])
|
||||||
processRoutines(table.unpack(e))
|
processRoutines(table.unpack(e))
|
||||||
|
Loading…
Reference in New Issue
Block a user