On Thu, 15 Mar 2018 15:44:18 +0000
Sichem Zhou <sichem...@gmail.com> wrote:

> Hi,
> 
> Sorry for the trouble, I forgot to ask that is it safe to call
> `wl_display_flush` and `wl_display_dispatch` in different threads?

Hi,

if you use threads, then you need to be using the prepare_read API of
libwayland-client. See the documentation for
wl_display_prepare_read_queue():
https://wayland.freedesktop.org/docs/html/apb.html#Client-classwl__display_1a40039c1169b153269a3dc0796a54ddb0

There is an example of the code sequence you must use in every thread,
that touches the wl_display or any wl object and needs to call poll()
or equivalent manually.

Please see the documentation of wl_display_dispatch() to see if you can
use it.

For every thread that dispatches events you will also need a separate
wl_event_queue, and you need to assign the wl objects to the correct
event queue unless the inherited event queue is already correct. For
assigning to a different event queue, you need to use
wl_proxy_create_wrapper() to avoid a race.

It is safe to call wl_display_flush() from different threads, but you
still need to ensure that it is really called before you expect poll()
to return with new events. This will be a concern if you send requests
from a thread that will not poll().


Thanks,
pq

Attachment: pgpfuLgXQXP9Q.pgp
Description: OpenPGP digital signature

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to