2022-01-19 13:48:59 +02:00
|
|
|
/* WirePlumber
|
|
|
|
|
*
|
|
|
|
|
* Copyright © 2022 Collabora Ltd.
|
|
|
|
|
* @author George Kiagiadakis <george.kiagiadakis@collabora.com>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef __WIREPLUMBER_EVENT_DISPATCHER_H__
|
|
|
|
|
#define __WIREPLUMBER_EVENT_DISPATCHER_H__
|
|
|
|
|
|
|
|
|
|
#include "core.h"
|
2022-11-29 20:08:13 +02:00
|
|
|
#include "event.h"
|
|
|
|
|
#include "event-hook.h"
|
2022-01-19 13:48:59 +02:00
|
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
2022-06-30 10:03:18 +05:30
|
|
|
/*! \defgroup wpeventdispatcher WpEventDispatcher */
|
2022-01-19 13:48:59 +02:00
|
|
|
/*!
|
2022-06-30 10:03:18 +05:30
|
|
|
* \struct WpEventDispatcher
|
|
|
|
|
*
|
|
|
|
|
* The event dispatcher holds all the events and hooks and dispatches them. It orchestras the show on event stack.
|
2022-01-19 13:48:59 +02:00
|
|
|
*/
|
|
|
|
|
#define WP_TYPE_EVENT_DISPATCHER (wp_event_dispatcher_get_type ())
|
|
|
|
|
WP_API
|
|
|
|
|
G_DECLARE_FINAL_TYPE (WpEventDispatcher, wp_event_dispatcher,
|
|
|
|
|
WP, EVENT_DISPATCHER, GObject)
|
|
|
|
|
|
|
|
|
|
WP_API
|
|
|
|
|
WpEventDispatcher * wp_event_dispatcher_get_instance (WpCore * core);
|
|
|
|
|
|
|
|
|
|
WP_API
|
|
|
|
|
void wp_event_dispatcher_push_event (WpEventDispatcher * self, WpEvent * event);
|
|
|
|
|
|
|
|
|
|
WP_API
|
|
|
|
|
void wp_event_dispatcher_register_hook (WpEventDispatcher * self,
|
|
|
|
|
WpEventHook * hook);
|
|
|
|
|
|
|
|
|
|
WP_API
|
|
|
|
|
void wp_event_dispatcher_unregister_hook (WpEventDispatcher * self,
|
|
|
|
|
WpEventHook * hook);
|
|
|
|
|
|
2022-11-25 21:26:34 +02:00
|
|
|
WP_API
|
event-dispatcher: Register hooks for defined events in a hash table
Since all the current hooks are defined specifically for a particular event
type, we can register the hooks in a hash table using the event type as key
for faster event hook collection.
Also, hooks that are not specific to a particular event type, like constraints
such as 'event.type=*', will be registered in both the undefined hook list,
and also in all the hash table defined hook lists so they are always evaluated.
Even though 'wp_event_dispatcher_new_hooks_iterator()' can still be used, it is
now marked as deprecated because it is slower. The event hook collection uses
'wp_event_dispatcher_new_hooks_for_event_type_iterator()' now because it is
much faster.
Previously, the more hooks we were registering, the slower WirePlumber would
process events as all hooks needed to be evaluated for all events constantly.
This is not the case anymore with this patch. We can register thousands of
hooks, and if only 1 of those runs for a particular event, only 1 will be
evaluated instead of all of them.
See #824
2025-11-20 16:36:37 -05:00
|
|
|
WpIterator * wp_event_dispatcher_new_hooks_iterator (WpEventDispatcher * self)
|
|
|
|
|
G_GNUC_DEPRECATED_FOR (wp_event_dispatcher_new_hooks_for_event_type_iterator);
|
|
|
|
|
|
|
|
|
|
WP_API
|
|
|
|
|
WpIterator * wp_event_dispatcher_new_hooks_for_event_type_iterator (
|
|
|
|
|
WpEventDispatcher * self, const gchar *event_type);
|
2022-11-25 21:26:34 +02:00
|
|
|
|
2022-01-19 13:48:59 +02:00
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
|
|
#endif
|