mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-07 13:29:55 -05:00
event-loop: Idle callback are a special case of a checked source
This commit is contained in:
parent
f8bb7f435b
commit
6ae42181c0
1 changed files with 8 additions and 11 deletions
|
|
@ -327,14 +327,19 @@ wl_event_loop_add_signal(struct wl_event_loop *loop,
|
||||||
struct wl_event_source_idle {
|
struct wl_event_source_idle {
|
||||||
struct wl_event_source base;
|
struct wl_event_source base;
|
||||||
wl_event_loop_idle_func_t func;
|
wl_event_loop_idle_func_t func;
|
||||||
void *data;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
wl_event_source_idle_dispatch(struct wl_event_source *source,
|
wl_event_source_idle_dispatch(struct wl_event_source *source,
|
||||||
struct epoll_event *ep)
|
struct epoll_event *ep)
|
||||||
{
|
{
|
||||||
assert(0);
|
struct wl_event_source_idle *idle_source =
|
||||||
|
(struct wl_event_source_idle *) source;
|
||||||
|
|
||||||
|
idle_source->func(idle_source->base.data);
|
||||||
|
wl_event_source_remove(&idle_source->base);
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
@ -371,6 +376,7 @@ wl_event_loop_add_idle(struct wl_event_loop *loop,
|
||||||
source->func = func;
|
source->func = func;
|
||||||
source->base.data = data;
|
source->base.data = data;
|
||||||
wl_list_insert(loop->idle_list.prev, &source->base.link);
|
wl_list_insert(loop->idle_list.prev, &source->base.link);
|
||||||
|
wl_event_source_check(&source->base);
|
||||||
|
|
||||||
return &source->base;
|
return &source->base;
|
||||||
}
|
}
|
||||||
|
|
@ -439,7 +445,6 @@ wl_event_loop_dispatch(struct wl_event_loop *loop, int timeout)
|
||||||
{
|
{
|
||||||
struct epoll_event ep[32];
|
struct epoll_event ep[32];
|
||||||
struct wl_event_source *source;
|
struct wl_event_source *source;
|
||||||
struct wl_event_source_idle *idle;
|
|
||||||
int i, count, n;
|
int i, count, n;
|
||||||
|
|
||||||
count = epoll_wait(loop->epoll_fd, ep, ARRAY_LENGTH(ep), timeout);
|
count = epoll_wait(loop->epoll_fd, ep, ARRAY_LENGTH(ep), timeout);
|
||||||
|
|
@ -453,14 +458,6 @@ wl_event_loop_dispatch(struct wl_event_loop *loop, int timeout)
|
||||||
|
|
||||||
while (n > 0)
|
while (n > 0)
|
||||||
n = post_dispatch_check(loop);
|
n = post_dispatch_check(loop);
|
||||||
|
|
||||||
while (!wl_list_empty(&loop->idle_list)) {
|
|
||||||
idle = container_of(loop->idle_list.next,
|
|
||||||
struct wl_event_source_idle, base.link);
|
|
||||||
wl_list_remove(&idle->base.link);
|
|
||||||
idle->func(idle->data);
|
|
||||||
free(idle);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue