[PATCH wayland] client: ensure thread safety for wl_display_roundtrip_queue()
Bill Spitzak
spitzak at gmail.com
Tue Feb 16 22:26:53 UTC 2016
On Mon, Feb 15, 2016 at 7:48 PM, Jonas Ã…dahl <jadahl at gmail.com> wrote:
The proxy wrapper approach can be tested out by appling this patch:
> https://lists.freedesktop.org/archives/wayland-devel/2015-June/023054.html
Paraphrased here:
> In short, instead of
>
> bar = wl_foo_get_bar(foo);
> wl_proxy_set_queue((struct wl_proxy *) bar, queue);
> wl_bar_add_listener(bar, ...);
>
> with this RFC a client does
>
> foo_wrapper = wl_proxy_create_wrapper((struct wl_proxy *) foo);
> wl_proxy_set_queue((struct wl_proxy *) foo_wrapper, queue);
> bar = wl_foo_get(foo_wrapper);
> wl_bar_add_listener(bar, ...);
This seems unnecessarily complex. Instead the wl_proxy can be in an
unassigned state (identified by the id being set to a special value that
will never be used otherwise). This avoids the extra object, allows the
same code to be used even if there are different constructors for bar, and
allows other setup before the id is assigned (for instance
wl_bar_add_listener is not thread safe and above examples rely on the queue
being the one belonging to the current thread):
bar = wl_bar_new();
wl_proxy_set_queue((struct wl_proxy*)bar, queue);
wl_bar_add_listener(bar, ...);
wl_foo_get_bar_id(foo, bar, ...);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20160216/a186187f/attachment-0001.html>
More information about the wayland-devel
mailing list