mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-07 13:30:09 -05:00
context: implement faster id collision check
Keep a sorted circular list of the globals by id. Keep all globals smaller than the current serial at the tail and the globals bigger in the front. When we wrap around we will eventually have a collision with the head global, we can then skip that id, move the global to the tail and try the next id. In the normal case, this is O(1) collision check and O(1) removal. In the case of a collisions, it needs to skip the cluster of used ids. See !1108
This commit is contained in:
parent
e241febe62
commit
8ca037683e
3 changed files with 33 additions and 15 deletions
|
|
@ -320,6 +320,7 @@ struct pw_global {
|
|||
struct pw_context *context; /**< the context */
|
||||
|
||||
struct spa_list link; /**< link in context list of globals */
|
||||
struct spa_list sorted_link; /**< link in context list of sorted_globals */
|
||||
uint32_t id; /**< server id of the object */
|
||||
|
||||
struct pw_properties *properties; /**< properties of the global */
|
||||
|
|
@ -451,6 +452,7 @@ struct pw_context {
|
|||
struct pw_array factory_lib; /**< mapping of factory_name regexp to library */
|
||||
|
||||
uint32_t serial;
|
||||
struct spa_list sorted_globals;
|
||||
struct pw_array objects; /**< objects */
|
||||
|
||||
struct pw_impl_client *current_client; /**< client currently executing code in mainloop */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue