Lines Matching refs:loop

93 static int uv__loops_add(uv_loop_t* loop) {  in uv__loops_add()  argument
109 uv__loops[uv__loops_size] = loop; in uv__loops_add()
121 static void uv__loops_remove(uv_loop_t* loop) { in uv__loops_remove() argument
129 if (uv__loops[loop_index] == loop) in uv__loops_remove()
167 uv_loop_t* loop; in uv__wake_all_loops() local
171 loop = uv__loops[i]; in uv__wake_all_loops()
172 assert(loop); in uv__wake_all_loops()
173 if (loop->iocp != INVALID_HANDLE_VALUE) in uv__wake_all_loops()
174 PostQueuedCompletionStatus(loop->iocp, 0, 0, NULL); in uv__wake_all_loops()
227 int uv_loop_init(uv_loop_t* loop) { in uv_loop_init() argument
236 loop->iocp = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 1); in uv_loop_init()
237 if (loop->iocp == NULL) in uv_loop_init()
243 loop->internal_fields = lfields; in uv_loop_init()
255 loop->time = 0; in uv_loop_init()
256 uv_update_time(loop); in uv_loop_init()
258 uv__queue_init(&loop->wq); in uv_loop_init()
259 uv__queue_init(&loop->handle_queue); in uv_loop_init()
260 loop->active_reqs.count = 0; in uv_loop_init()
261 loop->active_handles = 0; in uv_loop_init()
263 loop->pending_reqs_tail = NULL; in uv_loop_init()
265 loop->endgame_handles = NULL; in uv_loop_init()
267 loop->timer_heap = timer_heap = uv__malloc(sizeof(*timer_heap)); in uv_loop_init()
275 loop->check_handles = NULL; in uv_loop_init()
276 loop->prepare_handles = NULL; in uv_loop_init()
277 loop->idle_handles = NULL; in uv_loop_init()
279 loop->next_prepare_handle = NULL; in uv_loop_init()
280 loop->next_check_handle = NULL; in uv_loop_init()
281 loop->next_idle_handle = NULL; in uv_loop_init()
283 memset(&loop->poll_peer_sockets, 0, sizeof loop->poll_peer_sockets); in uv_loop_init()
285 loop->timer_counter = 0; in uv_loop_init()
286 loop->stop_flag = 0; in uv_loop_init()
288 err = uv_mutex_init(&loop->wq_mutex); in uv_loop_init()
292 err = uv_async_init(loop, &loop->wq_async, uv__work_done); in uv_loop_init()
296 uv__handle_unref(&loop->wq_async); in uv_loop_init()
297 loop->wq_async.flags |= UV_HANDLE_INTERNAL; in uv_loop_init()
299 err = uv__loops_add(loop); in uv_loop_init()
306 uv_mutex_destroy(&loop->wq_mutex); in uv_loop_init()
310 loop->timer_heap = NULL; in uv_loop_init()
317 loop->internal_fields = NULL; in uv_loop_init()
318 CloseHandle(loop->iocp); in uv_loop_init()
319 loop->iocp = INVALID_HANDLE_VALUE; in uv_loop_init()
325 void uv_update_time(uv_loop_t* loop) { in uv_update_time() argument
327 assert(new_time >= loop->time); in uv_update_time()
328 loop->time = new_time; in uv_update_time()
337 void uv__loop_close(uv_loop_t* loop) { in uv__loop_close() argument
341 uv__loops_remove(loop); in uv__loop_close()
349 loop->wq_async.async_sent = 0; in uv__loop_close()
350 loop->wq_async.close_cb = NULL; in uv__loop_close()
351 uv__handle_closing(&loop->wq_async); in uv__loop_close()
352 uv__handle_close(&loop->wq_async); in uv__loop_close()
354 for (i = 0; i < ARRAY_SIZE(loop->poll_peer_sockets); i++) { in uv__loop_close()
355 SOCKET sock = loop->poll_peer_sockets[i]; in uv__loop_close()
360 uv_mutex_lock(&loop->wq_mutex); in uv__loop_close()
361 assert(uv__queue_empty(&loop->wq) && "thread pool work queue not empty!"); in uv__loop_close()
362 assert(!uv__has_active_reqs(loop)); in uv__loop_close()
363 uv_mutex_unlock(&loop->wq_mutex); in uv__loop_close()
364 uv_mutex_destroy(&loop->wq_mutex); in uv__loop_close()
366 uv__free(loop->timer_heap); in uv__loop_close()
367 loop->timer_heap = NULL; in uv__loop_close()
369 lfields = uv__get_internal_fields(loop); in uv__loop_close()
372 loop->internal_fields = NULL; in uv__loop_close()
374 CloseHandle(loop->iocp); in uv__loop_close()
378 int uv__loop_configure(uv_loop_t* loop, uv_loop_option option, va_list ap) { in uv__loop_configure() argument
381 lfields = uv__get_internal_fields(loop); in uv__loop_configure()
391 int uv_backend_fd(const uv_loop_t* loop) { in uv_backend_fd() argument
396 int uv_loop_fork(uv_loop_t* loop) { in uv_loop_fork() argument
401 static int uv__loop_alive(const uv_loop_t* loop) { in uv__loop_alive() argument
402 return uv__has_active_handles(loop) || in uv__loop_alive()
403 uv__has_active_reqs(loop) || in uv__loop_alive()
404 loop->pending_reqs_tail != NULL || in uv__loop_alive()
405 loop->endgame_handles != NULL; in uv__loop_alive()
409 int uv_loop_alive(const uv_loop_t* loop) { in uv_loop_alive() argument
410 return uv__loop_alive(loop); in uv_loop_alive()
414 int uv_backend_timeout(const uv_loop_t* loop) { in uv_backend_timeout() argument
415 if (loop->stop_flag == 0 && in uv_backend_timeout()
417 (uv__has_active_handles(loop) || uv__has_active_reqs(loop)) && in uv_backend_timeout()
418 loop->pending_reqs_tail == NULL && in uv_backend_timeout()
419 loop->idle_handles == NULL && in uv_backend_timeout()
420 loop->endgame_handles == NULL) in uv_backend_timeout()
421 return uv__next_timeout(loop); in uv_backend_timeout()
426 static void uv__poll_wine(uv_loop_t* loop, DWORD timeout) { in uv__poll_wine() argument
437 lfields = uv__get_internal_fields(loop); in uv__poll_wine()
438 timeout_time = loop->time + timeout; in uv__poll_wine()
453 uv__metrics_set_provider_entry_time(loop); in uv__poll_wine()
461 GetQueuedCompletionStatus(loop->iocp, in uv__poll_wine()
469 uv__metrics_inc_events_waiting(loop, 1); in uv__poll_wine()
479 uv__metrics_update_idle_time(loop); in uv__poll_wine()
482 uv__metrics_inc_events(loop, 1); in uv__poll_wine()
486 uv__insert_pending_req(loop, req); in uv__poll_wine()
491 uv_update_time(loop); in uv__poll_wine()
499 uv_update_time(loop); in uv__poll_wine()
500 if (timeout_time > loop->time) { in uv__poll_wine()
501 timeout = (DWORD)(timeout_time - loop->time); in uv__poll_wine()
517 static void uv__poll(uv_loop_t* loop, DWORD timeout) { in uv__poll() argument
530 lfields = uv__get_internal_fields(loop); in uv__poll()
531 timeout_time = loop->time + timeout; in uv__poll()
548 uv__metrics_set_provider_entry_time(loop); in uv__poll()
556 success = pGetQueuedCompletionStatusEx(loop->iocp, in uv__poll()
573 uv__metrics_update_idle_time(loop); in uv__poll()
581 uv__metrics_inc_events(loop, 1); in uv__poll()
583 uv__metrics_inc_events_waiting(loop, 1); in uv__poll()
586 uv__insert_pending_req(loop, req); in uv__poll()
593 uv_update_time(loop); in uv__poll()
601 uv_update_time(loop); in uv__poll()
602 if (timeout_time > loop->time) { in uv__poll()
603 timeout = (DWORD)(timeout_time - loop->time); in uv__poll()
619 int uv_run(uv_loop_t *loop, uv_run_mode mode) { in uv_run() argument
624 r = uv__loop_alive(loop); in uv_run()
626 uv_update_time(loop); in uv_run()
632 if (mode == UV_RUN_DEFAULT && r != 0 && loop->stop_flag == 0) { in uv_run()
633 uv_update_time(loop); in uv_run()
634 uv__run_timers(loop); in uv_run()
637 while (r != 0 && loop->stop_flag == 0) { in uv_run()
638 can_sleep = loop->pending_reqs_tail == NULL && loop->idle_handles == NULL; in uv_run()
640 uv__process_reqs(loop); in uv_run()
641 uv__idle_invoke(loop); in uv_run()
642 uv__prepare_invoke(loop); in uv_run()
646 timeout = uv_backend_timeout(loop); in uv_run()
648 uv__metrics_inc_loop_count(loop); in uv_run()
651 uv__poll(loop, timeout); in uv_run()
653 uv__poll_wine(loop, timeout); in uv_run()
657 for (r = 0; r < 8 && loop->pending_reqs_tail != NULL; r++) in uv_run()
658 uv__process_reqs(loop); in uv_run()
665 uv__metrics_update_idle_time(loop); in uv_run()
667 uv__check_invoke(loop); in uv_run()
668 uv__process_endgames(loop); in uv_run()
670 uv_update_time(loop); in uv_run()
671 uv__run_timers(loop); in uv_run()
673 r = uv__loop_alive(loop); in uv_run()
681 if (loop->stop_flag != 0) in uv_run()
682 loop->stop_flag = 0; in uv_run()