Home | History | Annotate | Download | only in src

Lines Matching refs:source

55 	int (*dispatch)(struct wl_event_source *source,
74 wl_event_source_fd_dispatch(struct wl_event_source *source,
77 struct wl_event_source_fd *fd_source = (struct wl_event_source_fd *) source;
90 return fd_source->func(fd_source->fd, mask, source->data);
99 struct wl_event_source *source, uint32_t mask, void *data)
103 if (source->fd < 0) {
104 free(source);
108 source->loop = loop;
109 source->data = data;
110 wl_list_init(&source->link);
117 ep.data.ptr = source;
119 if (epoll_ctl(loop->epoll_fd, EPOLL_CTL_ADD, source->fd, &ep) < 0) {
120 close(source->fd);
121 free(source);
125 return source;
134 struct wl_event_source_fd *source;
136 source = malloc(sizeof *source);
137 if (source == NULL)
140 source->base.interface = &fd_source_interface;
141 source->base.fd = wl_os_dupfd_cloexec(fd, 0);
142 source->func = func;
143 source->fd = fd;
145 return add_source(loop, &source->base, mask, data);
149 wl_event_source_fd_update(struct wl_event_source *source, uint32_t mask)
151 struct wl_event_loop *loop = source->loop;
159 ep.data.ptr = source;
161 return epoll_ctl(loop->epoll_fd, EPOLL_CTL_MOD, source->fd, &ep);
170 wl_event_source_timer_dispatch(struct wl_event_source *source,
174 (struct wl_event_source_timer *) source;
178 len = read(source->fd, &expires, sizeof expires);
195 struct wl_event_source_timer *source;
197 source = malloc(sizeof *source);
198 if (source == NULL)
201 source->base.interface = &timer_source_interface;
202 source->base.fd = timerfd_create(CLOCK_MONOTONIC,
204 source->func = func;
206 return add_source(loop, &source->base, WL_EVENT_READABLE, data);
210 wl_event_source_timer_update(struct wl_event_source *source, int ms_delay)
218 if (timerfd_settime(source->fd, 0, &its, NULL) < 0)
231 wl_event_source_signal_dispatch(struct wl_event_source *source,
235 (struct wl_event_source_signal *) source;
239 len = read(source->fd, &signal_info, sizeof signal_info);
258 struct wl_event_source_signal *source;
261 source = malloc(sizeof *source);
262 if (source == NULL)
265 source->base.interface = &signal_source_interface;
266 source->signal_number = signal_number;
270 source->base.fd = signalfd(-1, &mask, SFD_CLOEXEC | SFD_NONBLOCK);
273 source->func = func;
275 return add_source(loop, &source->base, WL_EVENT_READABLE, data);
292 struct wl_event_source_idle *source;
294 source = malloc(sizeof *source);
295 if (source == NULL)
298 source->base.interface = &idle_source_interface;
299 source->base.loop = loop;
300 source->base.fd = -1;
302 source->func = func;
303 source->base.data = data;
305 wl_list_insert(loop->idle_list.prev, &source->base.link);
307 return &source->base;
311 wl_event_source_check(struct wl_event_source *source)
313 wl_list_insert(source->loop->check_list.prev, &source->link);
317 wl_event_source_remove(struct wl_event_source *source)
319 struct wl_event_loop *loop = source->loop;
323 if (source->fd >= 0) {
324 epoll_ctl(loop->epoll_fd, EPOLL_CTL_DEL, source->fd, NULL);
325 close(source->fd);
326 source->fd = -1;
329 wl_list_remove(&source->link);
330 wl_list_insert(&loop->destroy_list, &source->link);
338 struct wl_event_source *source, *next;
340 wl_list_for_each_safe(source, next, &loop->destroy_list, link)
341 free(source);
383 struct wl_event_source *source, *next;
388 wl_list_for_each_safe(source, next, &loop->check_list, link)
389 n += source->interface->dispatch(source, &ep);
397 struct wl_event_source_idle *source;
400 source = container_of(loop->idle_list.next,
402 source->func(source->base.data);
403 wl_event_source_remove(&source->base);
411 struct wl_event_source *source;
421 source = ep[i].data.ptr;
422 if (source->fd != -1)
423 source->interface->dispatch(source, &ep[i]);