Lines Matching refs:handle

61 int uv_timer_init(uv_loop_t* loop, uv_timer_t* handle) {
62 uv__handle_init(loop, (uv_handle_t*)handle, UV_TIMER);
63 handle->timer_cb = NULL;
64 handle->timeout = 0;
65 handle->repeat = 0;
70 int uv_timer_start(uv_timer_t* handle,
76 if (uv__is_closing(handle) || cb == NULL)
79 if (uv__is_active(handle))
80 uv_timer_stop(handle);
82 clamped_timeout = handle->loop->time + timeout;
86 handle->timer_cb = cb;
87 handle->timeout = clamped_timeout;
88 handle->repeat = repeat;
90 handle->start_id = handle->loop->timer_counter++;
93 handle->u.reserved[3] = (void*)LibuvCollectAsyncStack();
96 heap_insert(timer_heap(handle->loop),
97 (struct heap_node*) &handle->heap_node,
99 uv__handle_start(handle);
101 if (uv_check_data_valid((struct uv_loop_data*)handle->loop->data) == 0) {
102 uv_async_send(&handle->loop->wq_async);
109 int uv_timer_stop(uv_timer_t* handle) {
110 if (!uv__is_active(handle))
113 heap_remove(timer_heap(handle->loop),
114 (struct heap_node*) &handle->heap_node,
116 uv__handle_stop(handle);
122 int uv_timer_again(uv_timer_t* handle) {
123 if (handle->timer_cb == NULL)
126 if (handle->repeat) {
127 uv_timer_stop(handle);
128 uv_timer_start(handle, handle->timer_cb, handle->repeat, handle->repeat);
135 void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat) {
136 handle->repeat = repeat;
140 uint64_t uv_timer_get_repeat(const uv_timer_t* handle) {
141 return handle->repeat;
145 uint64_t uv_timer_get_due_in(const uv_timer_t* handle) {
146 if (handle->loop->time >= handle->timeout)
149 return handle->timeout - handle->loop->time;
155 const uv_timer_t* handle;
162 handle = container_of(heap_node, uv_timer_t, heap_node);
163 if (handle->timeout <= loop->time)
166 diff = handle->timeout - loop->time;
176 uv_timer_t* handle;
183 handle = container_of(heap_node, uv_timer_t, heap_node);
184 if (handle->timeout > loop->time)
187 uv_timer_stop(handle);
188 uv_timer_again(handle);
190 LibuvSetStackId((uint64_t)handle->u.reserved[3]);
192 handle->timer_cb(handle);
197 void uv__timer_close(uv_timer_t* handle) {
198 uv_timer_stop(handle);