Lines Matching refs:handle
58 int uv_timer_init(uv_loop_t* loop, uv_timer_t* handle) { in uv_timer_init() argument
59 uv__handle_init(loop, (uv_handle_t*)handle, UV_TIMER); in uv_timer_init()
60 handle->timer_cb = NULL; in uv_timer_init()
61 handle->timeout = 0; in uv_timer_init()
62 handle->repeat = 0; in uv_timer_init()
63 uv__queue_init(&handle->node.queue); in uv_timer_init()
68 int uv_timer_start(uv_timer_t* handle, in uv_timer_start() argument
74 if (uv__is_closing(handle) || cb == NULL) in uv_timer_start()
77 uv_timer_stop(handle); in uv_timer_start()
79 clamped_timeout = handle->loop->time + timeout; in uv_timer_start()
83 handle->timer_cb = cb; in uv_timer_start()
84 handle->timeout = clamped_timeout; in uv_timer_start()
85 handle->repeat = repeat; in uv_timer_start()
87 handle->start_id = handle->loop->timer_counter++; in uv_timer_start()
89 heap_insert(timer_heap(handle->loop), in uv_timer_start()
90 (struct heap_node*) &handle->node.heap, in uv_timer_start()
92 uv__handle_start(handle); in uv_timer_start()
98 int uv_timer_stop(uv_timer_t* handle) { in uv_timer_stop() argument
99 if (uv__is_active(handle)) { in uv_timer_stop()
100 heap_remove(timer_heap(handle->loop), in uv_timer_stop()
101 (struct heap_node*) &handle->node.heap, in uv_timer_stop()
103 uv__handle_stop(handle); in uv_timer_stop()
105 uv__queue_remove(&handle->node.queue); in uv_timer_stop()
108 uv__queue_init(&handle->node.queue); in uv_timer_stop()
113 int uv_timer_again(uv_timer_t* handle) { in uv_timer_again() argument
114 if (handle->timer_cb == NULL) in uv_timer_again()
117 if (handle->repeat) { in uv_timer_again()
118 uv_timer_stop(handle); in uv_timer_again()
119 uv_timer_start(handle, handle->timer_cb, handle->repeat, handle->repeat); in uv_timer_again()
126 void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat) { in uv_timer_set_repeat() argument
127 handle->repeat = repeat; in uv_timer_set_repeat()
131 uint64_t uv_timer_get_repeat(const uv_timer_t* handle) { in uv_timer_get_repeat() argument
132 return handle->repeat; in uv_timer_get_repeat()
136 uint64_t uv_timer_get_due_in(const uv_timer_t* handle) { in uv_timer_get_due_in() argument
137 if (handle->loop->time >= handle->timeout) in uv_timer_get_due_in()
140 return handle->timeout - handle->loop->time; in uv_timer_get_due_in()
146 const uv_timer_t* handle; in uv__next_timeout() local
153 handle = container_of(heap_node, uv_timer_t, node.heap); in uv__next_timeout()
154 if (handle->timeout <= loop->time) in uv__next_timeout()
157 diff = handle->timeout - loop->time; in uv__next_timeout()
167 uv_timer_t* handle; in uv__run_timers() local
178 handle = container_of(heap_node, uv_timer_t, node.heap); in uv__run_timers()
179 if (handle->timeout > loop->time) in uv__run_timers()
182 uv_timer_stop(handle); in uv__run_timers()
183 uv__queue_insert_tail(&ready_queue, &handle->node.queue); in uv__run_timers()
190 handle = container_of(queue_node, uv_timer_t, node.queue); in uv__run_timers()
192 uv_timer_again(handle); in uv__run_timers()
193 handle->timer_cb(handle); in uv__run_timers()
198 void uv__timer_close(uv_timer_t* handle) { in uv__timer_close() argument
199 uv_timer_stop(handle); in uv__timer_close()