[PATCH] event-loop: export wl_event_loop_dispatch_idle()

Kristian Høgsberg hoegsberg at gmail.com
Wed Sep 12 09:28:37 PDT 2012


On Tue, Sep 11, 2012 at 04:09:34PM +0200, David Herrmann wrote:
> When integrating the wayland event-loop into another event-loop, we
> currently have no chance of checking whether there are pending idle
> sources that have to be called. This patch exports the
> "dispatch_idle_sources()" call so other event loops can call this before
> going to sleep. This is what wl_event_loop_dispatch() currently does so we
> simply allow external event-loops to do the same now.
> 
> To avoid breaking existing applications, we keep the call to
> dispatch_idle_sources() in wl_event_loop_dispatch() for now. However, if
> we want we can remove this later and require every application to call
> this manually. This needs to be discussed, but the overhead is negligible
> so we will probably leave it as it is.
> 
> This finally allows to fully integrate the wayland-server API into
> existing event-loops without any nasty workarounds.

Committed, thanks for making this work.

Kristian


> Signed-off-by: David Herrmann <dh.herrmann at googlemail.com>
> ---
>  src/event-loop.c     | 6 +++---
>  src/wayland-server.h | 1 +
>  2 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/src/event-loop.c b/src/event-loop.c
> index df4b8b8..9339226 100644
> --- a/src/event-loop.c
> +++ b/src/event-loop.c
> @@ -378,8 +378,8 @@ post_dispatch_check(struct wl_event_loop *loop)
>  	return n;
>  }
>  
> -static void
> -dispatch_idle_sources(struct wl_event_loop *loop)
> +WL_EXPORT void
> +wl_event_loop_dispatch_idle(struct wl_event_loop *loop)
>  {
>  	struct wl_event_source_idle *source;
>  
> @@ -398,7 +398,7 @@ wl_event_loop_dispatch(struct wl_event_loop *loop, int timeout)
>  	struct wl_event_source *source;
>  	int i, count, n;
>  
> -	dispatch_idle_sources(loop);
> +	wl_event_loop_dispatch_idle(loop);
>  
>  	count = epoll_wait(loop->epoll_fd, ep, ARRAY_LENGTH(ep), timeout);
>  	if (count < 0)
> diff --git a/src/wayland-server.h b/src/wayland-server.h
> index 3c56729..45cc61c 100644
> --- a/src/wayland-server.h
> +++ b/src/wayland-server.h
> @@ -67,6 +67,7 @@ void wl_event_source_check(struct wl_event_source *source);
>  
>  
>  int wl_event_loop_dispatch(struct wl_event_loop *loop, int timeout);
> +void wl_event_loop_dispatch_idle(struct wl_event_loop *loop);
>  struct wl_event_source *wl_event_loop_add_idle(struct wl_event_loop *loop,
>  					       wl_event_loop_idle_func_t func,
>  					       void *data);
> -- 
> 1.7.12
> 


More information about the wayland-devel mailing list