mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2025-12-24 21:20:03 +01:00
Previously the correct hook execution order was calculated for each event, reevaluating the (reverse) dependencies of every applicable hook. Since the set of hooks is mostly static, this does a lot of work again and again. Instead of doing that, sort the hooks topologically using Kahn's algorithm when a hook is registered to avoid the extra work. This also allows the detection of circular dependencies at hook registration time. After this change, collecting the matching hooks is a simple linear scan because they are already in the correct order. Sorting the hooks when a hook is unregistered is not needed. Note, that previously circular dependencies were allowed if there was no event that matched both hooks. After this change circular dependencies are detected globally, between all hooks. See #824
51 lines
1.3 KiB
C
51 lines
1.3 KiB
C
/* 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"
|
|
#include "event.h"
|
|
#include "event-hook.h"
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
/*! \defgroup wpeventdispatcher WpEventDispatcher */
|
|
/*!
|
|
* \struct WpEventDispatcher
|
|
*
|
|
* The event dispatcher holds all the events and hooks and dispatches them. It orchestras the show on event stack.
|
|
*/
|
|
#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);
|
|
|
|
WP_API
|
|
WpIterator * wp_event_dispatcher_new_hooks_iterator (WpEventDispatcher * self);
|
|
|
|
WP_API
|
|
size_t wp_event_dispatcher_get_hooks_for_event (WpEventDispatcher * self, WpEvent * event, GPtrArray * res);
|
|
|
|
G_END_DECLS
|
|
|
|
#endif
|