aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2015-12-23 11:17:26 +0000
committerMatthew Wild <mwild1@gmail.com>2015-12-23 11:17:26 +0000
commitc0d46cbf2a388233fc521743605c59a465e7acda (patch)
treecc01a9170dddc27d721fbe2ec9db9bdf50d7ccc6
parent9119466510c4ecdd67a43a74427f24f249436229 (diff)
downloadprosody-c0d46cbf2a388233fc521743605c59a465e7acda.tar.gz
prosody-c0d46cbf2a388233fc521743605c59a465e7acda.zip
util.events: Document data structures
-rw-r--r--util/events.lua5
1 files changed, 5 insertions, 0 deletions
diff --git a/util/events.lua b/util/events.lua
index 825ffb19..073d2a60 100644
--- a/util/events.lua
+++ b/util/events.lua
@@ -17,10 +17,15 @@ local next = next;
local _ENV = nil;
local function new()
+ -- Map event name to ordered list of handlers (lazily built): handlers[event_name] = array_of_handler_functions
local handlers = {};
+ -- Array of wrapper functions that wrap all events (nil if empty)
local global_wrappers;
+ -- Per-event wrappers: wrappers[event_name] = wrapper_function
local wrappers = {};
+ -- Event map: event_map[handler_function] = priority_number
local event_map = {};
+ -- Called on-demand to build handlers entries
local function _rebuild_index(handlers, event)
local _handlers = event_map[event];
if not _handlers or next(_handlers) == nil then return; end