[PATCH wayland] client: Add an entry point for dispatching a queue without blocking

Kristian Høgsberg hoegsberg at gmail.com
Fri Nov 23 19:46:19 PST 2012


On Thu, Nov 22, 2012 at 03:34:48PM +0200, Ander Conselvan de Oliveira wrote:
> On the client side EGL, all the wl_buffer.release events need to be
> processed before buffer allocation, otherwise a third buffer might
> be allocated unnecessarily. However, the buffer allocation should
> not block in the case no event was received. In order to do that, a
> non-blocking queue dispatch function is needed.

Yes, we need this.  Patch looks good, pretty straight forward and
documented.  Committed.  For the interim (ie until we release 1.0.2
with this fix), we need a mechanism to track API additions so that we
can test for them in dependent libraries (eg mesa).  I wonder if we
can just have an API version that we increase whenever we add to the
API.  This would be just a monotonically increasing integer.  We add

#define WAYLAND_CLIENT_API_VERSION 1

to src/wayland-version.h.in and just manually increment it whenever we
add new client API.  Then in mesa we can do

#if WAYLAND_CLIENT_API_VERSION >= 1
   wl_display_dispatch_queue(blah);
#endif

Or maybe we should just release 1.0.2 sooner  rather than later...

Kristian

> ---
>  src/wayland-client.c |   19 +++++++++++++++++++
>  src/wayland-client.h |    2 ++
>  2 files changed, 21 insertions(+)
> 
> diff --git a/src/wayland-client.c b/src/wayland-client.c
> index d3a7970..9d10f89 100644
> --- a/src/wayland-client.c
> +++ b/src/wayland-client.c
> @@ -926,6 +926,25 @@ wl_display_dispatch_queue(struct wl_display *display,
>  	return dispatch_queue(display, queue, 1);
>  }
>  
> +/** Dispatch pending events in an event queue
> + *
> + * \param display The display context object
> + * \param queue The event queue to dispatch
> + * \return The number of dispatched events on success or -1 on failure
> + *
> + * Dispatch all incoming events for objects assigned to the given
> + * event queue. On failure -1 is returned and errno set appropriately.
> + * If there are no events queued, this functions return immediately.
> + *
> + * \memberof wl_display
> + */
> +WL_EXPORT int
> +wl_display_dispatch_queue_pending(struct wl_display *display,
> +				  struct wl_event_queue *queue)
> +{
> +	return dispatch_queue(display, queue, 0);
> +}
> +
>  /** Process incoming events
>   *
>   * \param display The display context object
> diff --git a/src/wayland-client.h b/src/wayland-client.h
> index 71fe450..8d2b8df 100644
> --- a/src/wayland-client.h
> +++ b/src/wayland-client.h
> @@ -145,6 +145,8 @@ int wl_display_get_fd(struct wl_display *display);
>  int wl_display_dispatch(struct wl_display *display);
>  int wl_display_dispatch_queue(struct wl_display *display,
>  			      struct wl_event_queue *queue);
> +int wl_display_dispatch_queue_pending(struct wl_display *display,
> +				      struct wl_event_queue *queue);
>  int wl_display_dispatch_pending(struct wl_display *display);
>  int wl_display_get_error(struct wl_display *display);
>  
> -- 
> 1.7.10.4
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list