[PATCH] client: Add acquire-fd API to avoid requiring a polling main thread
Bill Spitzak
spitzak at gmail.com
Wed Apr 10 10:29:04 PDT 2013
Can wl_display_acquire_fd be merged into wl_display_dispatch_pending()?
It looks like you never want to call one without the other, and it also
appears that wl_display_dispatch releases it so this would be symmetric.
On 04/10/2013 08:16 AM, Kristian Høgsberg wrote:
> wl_display_dispatch_pending(display);
>
> /* Race here if other thread reads from fd and places events
> * in main eent queue. We go to sleep in poll while sitting on
> * events that may stall the application if not dispatched. */
>
> poll(fds, nfds, -1);
>
> /* Race here if other thread reads and doesn't queue any
> * events for main queue. wl_display_dispatch() below will block
> * trying to read from the fd, while other fds in the mainloop
> * are ignored. */
>
> wl_display_dispatch(display);
>
> The restriction that only the main thread can read from the fd avoids
> these races, but has the problems described above.
>
> This patch introduces new API to solve both problems. We add
>
> int wl_display_acquire_fd(struct wl_display *display);
More information about the wayland-devel
mailing list