Lines Matching refs:timers
78 struct wl_timer_heap timers; member
282 wl_timer_heap_init(struct wl_timer_heap *timers, struct wl_event_loop *loop) in wl_timer_heap_init() argument
284 timers->base.fd = -1; in wl_timer_heap_init()
285 timers->base.data = NULL; in wl_timer_heap_init()
286 wl_list_init(&timers->base.link); in wl_timer_heap_init()
287 timers->base.interface = &timer_heap_source_interface; in wl_timer_heap_init()
288 timers->base.loop = loop; in wl_timer_heap_init()
290 loop->timers.data = NULL; in wl_timer_heap_init()
291 loop->timers.active = 0; in wl_timer_heap_init()
292 loop->timers.space = 0; in wl_timer_heap_init()
293 loop->timers.count = 0; in wl_timer_heap_init()
297 wl_timer_heap_release(struct wl_timer_heap *timers) in wl_timer_heap_release() argument
299 if (timers->base.fd != -1) { in wl_timer_heap_release()
300 close(timers->base.fd); in wl_timer_heap_release()
302 free(timers->data); in wl_timer_heap_release()
306 wl_timer_heap_ensure_timerfd(struct wl_timer_heap *timers) in wl_timer_heap_ensure_timerfd() argument
311 if (timers->base.fd != -1) in wl_timer_heap_ensure_timerfd()
316 ep.data.ptr = timers; in wl_timer_heap_ensure_timerfd()
323 if (epoll_ctl(timers->base.loop->epoll_fd, in wl_timer_heap_ensure_timerfd()
329 timers->base.fd = timer_fd; in wl_timer_heap_ensure_timerfd()
334 wl_timer_heap_reserve(struct wl_timer_heap *timers) in wl_timer_heap_reserve() argument
339 if (timers->count + 1 > timers->space) { in wl_timer_heap_reserve()
340 new_space = timers->space >= 8 ? timers->space * 2 : 8; in wl_timer_heap_reserve()
341 n = realloc(timers->data, (size_t)new_space * sizeof(*n)); in wl_timer_heap_reserve()
346 timers->data = n; in wl_timer_heap_reserve()
347 timers->space = new_space; in wl_timer_heap_reserve()
350 timers->count++; in wl_timer_heap_reserve()
355 wl_timer_heap_unreserve(struct wl_timer_heap *timers) in wl_timer_heap_unreserve() argument
359 timers->count--; in wl_timer_heap_unreserve()
361 if (timers->space >= 16 && timers->space >= 4 * timers->count) { in wl_timer_heap_unreserve()
362 n = realloc(timers->data, (size_t)timers->space / 2 * sizeof(*n)); in wl_timer_heap_unreserve()
367 timers->data = n; in wl_timer_heap_unreserve()
368 timers->space = timers->space / 2; in wl_timer_heap_unreserve()
443 wl_timer_heap_disarm(struct wl_timer_heap *timers, in wl_timer_heap_disarm() argument
456 last_end_evt = timers->data[timers->active - 1]; in wl_timer_heap_disarm()
457 timers->data[timers->active - 1] = NULL; in wl_timer_heap_disarm()
458 timers->active--; in wl_timer_heap_disarm()
460 if (old_source_idx == timers->active) in wl_timer_heap_disarm()
463 timers->data[old_source_idx] = last_end_evt; in wl_timer_heap_disarm()
468 heap_sift_down(timers->data, timers->active, last_end_evt); in wl_timer_heap_disarm()
469 heap_sift_up(timers->data, last_end_evt); in wl_timer_heap_disarm()
474 wl_timer_heap_arm(struct wl_timer_heap *timers, in wl_timer_heap_arm() argument
481 timers->data[timers->active] = source; in wl_timer_heap_arm()
482 source->heap_idx = timers->active; in wl_timer_heap_arm()
483 timers->active++; in wl_timer_heap_arm()
484 heap_sift_up(timers->data, source); in wl_timer_heap_arm()
489 wl_timer_heap_dispatch(struct wl_timer_heap *timers) in wl_timer_heap_dispatch() argument
497 while (timers->active > 0) { in wl_timer_heap_dispatch()
498 root = timers->data[0]; in wl_timer_heap_dispatch()
502 wl_timer_heap_disarm(timers, root); in wl_timer_heap_dispatch()
513 if (timers->active > 0) { in wl_timer_heap_dispatch()
514 if (set_timer(timers->base.fd, timers->data[0]->deadline) < 0) in wl_timer_heap_dispatch()
517 if (clear_timer(timers->base.fd) < 0) in wl_timer_heap_dispatch()
568 if (wl_timer_heap_ensure_timerfd(&loop->timers) < 0) in wl_event_loop_add_timer()
586 if (wl_timer_heap_reserve(&loop->timers) < 0) { in wl_event_loop_add_timer()
615 struct wl_timer_heap *timers = &tsource->base.loop->timers; in wl_event_source_timer_update() local
630 wl_timer_heap_arm(timers, tsource, deadline); in wl_event_source_timer_update()
633 heap_sift_up(timers->data, tsource); in wl_event_source_timer_update()
636 heap_sift_down(timers->data, timers->active, tsource); in wl_event_source_timer_update()
642 if (set_timer(timers->base.fd, deadline) < 0) in wl_event_source_timer_update()
648 wl_timer_heap_disarm(timers, tsource); in wl_event_source_timer_update()
650 if (timers->active == 0) { in wl_event_source_timer_update()
653 if (clear_timer(timers->base.fd) < 0) in wl_event_source_timer_update()
846 wl_timer_heap_unreserve(&loop->timers); in wl_event_source_remove()
903 wl_timer_heap_init(&loop->timers, loop); in wl_event_loop_create()
927 wl_timer_heap_release(&loop->timers); in wl_event_loop_destroy()
1010 if (source == &loop->timers.base) in wl_event_loop_dispatch()
1020 if (wl_timer_heap_dispatch(&loop->timers) < 0) in wl_event_loop_dispatch()