Proposed rearrangement of wl_event_loop_dispatch
Bill Spitzak
spitzak at gmail.com
Mon Jul 9 17:44:20 PDT 2012
David Herrmann wrote:
> Hi Bill
>
> On Mon, Jul 9, 2012 at 8:06 PM, Bill Spitzak <spitzak at gmail.com> wrote:
>> Any comments on this?
>>
>
> It is much easier to comment on and follow patches if you include them
> inline. Also, where is the git headline? I recommend using
> git-format-patch and optionally git-send-email (even for RFC patches).
I did not actually commit this in git, as I was more like trying to ask
a question. I think a real patch would involve renaming post_dispatch to
something better describing how I am using it.
> Regarding your patch:
> Why do you continuously set "timeout" to 0 during the loop? It should
> be sufficient to set it one time only. Also, please add a newline
> after while() but before the loop-body.
Equivalent code that only sets it once, but I'm not thrilled with this
because it duplicates the post_dispatch line:
if (post_dispatch_check(loop) > 0) {
timeout = 0;
while (post_dispatch_check(loop) > 0);
}
Here is the patch as an inline version:
diff --git a/src/event-loop.c b/src/event-loop.c
index a839daf..11da605 100644
--- a/src/event-loop.c
+++ b/src/event-loop.c
@@ -400,6 +400,8 @@ wl_event_loop_dispatch(struct wl_event_loop *loop,
int timeout)
dispatch_idle_sources(loop);
+ while (post_dispatch_check(loop) > 0) timeout = 0;
+
count = epoll_wait(loop->epoll_fd, ep, ARRAY_LENGTH(ep), timeout);
if (count < 0)
return -1;
@@ -411,10 +413,6 @@ wl_event_loop_dispatch(struct wl_event_loop *loop,
int timeout)
}
wl_event_loop_process_destroy_list(loop);
-
- do {
- n = post_dispatch_check(loop);
- } while (n > 0);
return 0;
}
More information about the wayland-devel
mailing list