event-dispatcher: refactor to use before/after dependencies on hooks

* Remove entirely the hook priority numbers and use before/after dependencies
* Split the WpEvent code out of WpEventDispatcher
* Add methods on WpEvent to interface with it from the WpEventDispatcher.
  As a bonus, we can now also implement tooling to inspect which hooks would
  in theory run for an event and write tests around that
* Removed some internal debugging facilities and log calls, will redo it later.
* Using spa_list now for the list of hooks, to reduce the number of allocations
  happening in the "hook collection" algorithm
* Switched some internal data to use g_new0 instead of g_slice_new0
* Added g_free to free WpEvent structures... surprisingly, we were leaking them
  before
This commit is contained in:
George Kiagiadakis
2022-11-29 20:08:13 +02:00
committed by Julian Bouzas
parent 5a435fae11
commit 3a23fb451a
15 changed files with 1019 additions and 519 deletions

View File

@@ -151,7 +151,7 @@ wp_default_nodes_api_enable (WpPlugin * plugin, WpTransition * transition)
/* default metadata added */
hook = wp_simple_event_hook_new ("metadata-added@default-nodes-api",
WP_EVENT_HOOK_PRIORITY_NORMAL,
NULL, NULL,
g_cclosure_new ((GCallback) on_metadata_added, self, NULL));
wp_interest_event_hook_add_interest (WP_INTEREST_EVENT_HOOK (hook),
WP_CONSTRAINT_TYPE_PW_PROPERTY, "event.type", "=s", "metadata-added",
@@ -162,7 +162,7 @@ wp_default_nodes_api_enable (WpPlugin * plugin, WpTransition * transition)
/* default metadata changed */
hook = wp_simple_event_hook_new ("metadata-changed@default-nodes-api",
WP_EVENT_HOOK_PRIORITY_NORMAL,
NULL, NULL,
g_cclosure_new ((GCallback) on_metadata_changed_hook, self, NULL));
wp_interest_event_hook_add_interest (WP_INTEREST_EVENT_HOOK (hook),