mirror of
https://github.com/Lacustat/Freewood-OctoWoW-Core.git
synced 2026-10-30 18:17:00 +00:00
0.1.169: Zeitmesser-Haken in FW:Fire und Dispatch
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016onJCSHLwhs9udhC9ZLzk9
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
239583652d
commit
1402a910db
+18
-4
@@ -119,6 +119,8 @@ function FW:Off(event, owner)
|
||||
end
|
||||
end
|
||||
|
||||
-- Zeitmesser-Haken (setzt das Dev-Modul): FW.ProfEnter(art, ereignis, eintrag) -> Tiefe oder nil, FW.ProfLeave(tiefe, art, ereignis, eintrag).
|
||||
-- Ohne Dev-Modul kostet das je Aufruf nur eine nil-Pruefung. Die Haken laufen geschuetzt, ein Fehler dort bricht nichts ab.
|
||||
function FW:Fire(event, ...)
|
||||
local list = callbacks[event]
|
||||
if not list then
|
||||
@@ -128,13 +130,20 @@ function FW:Fire(event, ...)
|
||||
for i = 1, #list do
|
||||
snapshot[i] = list[i]
|
||||
end
|
||||
local enter, leave = FW.ProfEnter, FW.ProfLeave
|
||||
for i = 1, #snapshot do
|
||||
local cb = snapshot[i]
|
||||
local depth
|
||||
if enter then
|
||||
local ok, d = pcall(enter, "fire", event, cb)
|
||||
if ok then depth = d end
|
||||
end
|
||||
if cb.owner then
|
||||
SafeCall(cb.fn, cb.owner, ...)
|
||||
else
|
||||
SafeCall(cb.fn, ...)
|
||||
end
|
||||
if depth then pcall(leave, depth, "fire", event, cb) end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -211,17 +220,22 @@ local function Dispatch(list, ...)
|
||||
for i = 1, #list do
|
||||
snapshot[i] = list[i]
|
||||
end
|
||||
-- Zeitmesser (Dev-Reiter): FW.HandlerTimer(event, ms, owner), nur wenn gesetzt
|
||||
local hook, prof = FW.HandlerTimer, _G.debugprofilestop
|
||||
-- Zeitmesser (Dev-Modul): siehe FW:Fire
|
||||
local enter, leave = FW.ProfEnter, FW.ProfLeave
|
||||
local event = curEvent
|
||||
for i = 1, #snapshot do
|
||||
local h = snapshot[i]
|
||||
local t0 = hook and prof and prof()
|
||||
local depth
|
||||
if enter then
|
||||
local ok, d = pcall(enter, "event", event, h)
|
||||
if ok then depth = d end
|
||||
end
|
||||
if h.owner then
|
||||
SafeCall(h.fn, h.owner, ...)
|
||||
else
|
||||
SafeCall(h.fn, ...)
|
||||
end
|
||||
if t0 then hook(curEvent, prof() - t0, h.owner) end
|
||||
if depth then pcall(leave, depth, "event", event, h) end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user