mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-05 13:29:50 -05:00
Split the global registry into its own wl_registry object
The only way to make the global object listener interface thread safe is to make it its own interface and make different listeners different wl_proxies. The core of the problem is the callback we do when a global show up or disappears, which we can't do with a lock held. On the other hand we can't iterate the global list or the listener list without a lock held as new globals or listeners may come and go during the iteration. Making a copy of the list under the lock and then iterating after dropping the lock wont work either. In case of the listener list, once we drop the lock another thread may unregister a listener and destroy the callbackk data, which means that when we eventually call that listener we'll pass it free memory and break everything. We did already solve the thread-safe callback problem, however. It's what we do for all protocol events. So we can just make the global registry functionality its own new interface and give each thread its own proxy. That way, the thread will do its own callbacks (with no locks held) and destroy the proxy when it's no longer interested in wl_registry events.
This commit is contained in:
parent
8872956dfd
commit
9fe75537ad
4 changed files with 72 additions and 162 deletions
|
|
@ -68,22 +68,6 @@ int wl_display_flush(struct wl_display *display);
|
|||
void wl_display_roundtrip(struct wl_display *display);
|
||||
struct wl_event_queue *wl_display_create_queue(struct wl_display *display);
|
||||
|
||||
struct wl_global_listener;
|
||||
typedef void (*wl_display_global_func_t)(struct wl_display *display,
|
||||
uint32_t id,
|
||||
const char *interface,
|
||||
uint32_t version,
|
||||
void *data);
|
||||
void
|
||||
wl_display_remove_global_listener(struct wl_display *display,
|
||||
struct wl_global_listener *listener);
|
||||
struct wl_global_listener *
|
||||
wl_display_add_global_listener(struct wl_display *display,
|
||||
wl_display_global_func_t handler, void *data);
|
||||
uint32_t
|
||||
wl_display_get_global(struct wl_display *display,
|
||||
const char *interface, uint32_t version);
|
||||
|
||||
void wl_log_set_handler_client(wl_log_func_t handler);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue