• Home
  • Raw
  • Download

Lines Matching refs:eloop

72 static struct eloop_data eloop;  variable
77 os_memset(&eloop, 0, sizeof(eloop)); in eloop_init()
78 dl_list_init(&eloop.timeout); in eloop_init()
79 eloop.num_handles = 1; in eloop_init()
80 eloop.handles = os_malloc(eloop.num_handles * in eloop_init()
81 sizeof(eloop.handles[0])); in eloop_init()
82 if (eloop.handles == NULL) in eloop_init()
85 eloop.term_event = CreateEvent(NULL, FALSE, FALSE, NULL); in eloop_init()
86 if (eloop.term_event == NULL) { in eloop_init()
89 os_free(eloop.handles); in eloop_init()
101 if (eloop.num_handles > eloop.reader_count + eloop.event_count + 8) in eloop_prepare_handles()
103 n = os_realloc_array(eloop.handles, eloop.num_handles * 2, in eloop_prepare_handles()
104 sizeof(eloop.handles[0])); in eloop_prepare_handles()
107 eloop.handles = n; in eloop_prepare_handles()
108 eloop.num_handles *= 2; in eloop_prepare_handles()
133 tmp = os_realloc_array(eloop.readers, eloop.reader_count + 1, in eloop_register_read_sock()
141 tmp[eloop.reader_count].sock = sock; in eloop_register_read_sock()
142 tmp[eloop.reader_count].eloop_data = eloop_data; in eloop_register_read_sock()
143 tmp[eloop.reader_count].user_data = user_data; in eloop_register_read_sock()
144 tmp[eloop.reader_count].handler = handler; in eloop_register_read_sock()
145 tmp[eloop.reader_count].event = event; in eloop_register_read_sock()
146 eloop.reader_count++; in eloop_register_read_sock()
147 eloop.readers = tmp; in eloop_register_read_sock()
148 if (sock > eloop.max_sock) in eloop_register_read_sock()
149 eloop.max_sock = sock; in eloop_register_read_sock()
150 eloop.reader_table_changed = 1; in eloop_register_read_sock()
160 if (eloop.readers == NULL || eloop.reader_count == 0) in eloop_unregister_read_sock()
163 for (i = 0; i < eloop.reader_count; i++) { in eloop_unregister_read_sock()
164 if (eloop.readers[i].sock == sock) in eloop_unregister_read_sock()
167 if (i == eloop.reader_count) in eloop_unregister_read_sock()
170 WSAEventSelect(eloop.readers[i].sock, eloop.readers[i].event, 0); in eloop_unregister_read_sock()
171 WSACloseEvent(eloop.readers[i].event); in eloop_unregister_read_sock()
173 if (i != eloop.reader_count - 1) { in eloop_unregister_read_sock()
174 os_memmove(&eloop.readers[i], &eloop.readers[i + 1], in eloop_unregister_read_sock()
175 (eloop.reader_count - i - 1) * in eloop_unregister_read_sock()
178 eloop.reader_count--; in eloop_unregister_read_sock()
179 eloop.reader_table_changed = 1; in eloop_unregister_read_sock()
196 tmp = os_realloc_array(eloop.events, eloop.event_count + 1, in eloop_register_event()
201 tmp[eloop.event_count].eloop_data = eloop_data; in eloop_register_event()
202 tmp[eloop.event_count].user_data = user_data; in eloop_register_event()
203 tmp[eloop.event_count].handler = handler; in eloop_register_event()
204 tmp[eloop.event_count].event = h; in eloop_register_event()
205 eloop.event_count++; in eloop_register_event()
206 eloop.events = tmp; in eloop_register_event()
217 if (eloop.events == NULL || eloop.event_count == 0 || in eloop_unregister_event()
221 for (i = 0; i < eloop.event_count; i++) { in eloop_unregister_event()
222 if (eloop.events[i].event == h) in eloop_unregister_event()
225 if (i == eloop.event_count) in eloop_unregister_event()
228 if (i != eloop.event_count - 1) { in eloop_unregister_event()
229 os_memmove(&eloop.events[i], &eloop.events[i + 1], in eloop_unregister_event()
230 (eloop.event_count - i - 1) * in eloop_unregister_event()
233 eloop.event_count--; in eloop_unregister_event()
273 dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) { in eloop_register_timeout()
279 dl_list_add_tail(&eloop.timeout, &timeout->list); in eloop_register_timeout()
298 dl_list_for_each_safe(timeout, prev, &eloop.timeout, in eloop_cancel_timeout()
325 dl_list_for_each_safe(timeout, prev, &eloop.timeout, in eloop_cancel_timeout_one()
346 dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) { in eloop_is_timeout_registered()
364 dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) { in eloop_deplete_timeout()
396 dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) { in eloop_replenish_timeout()
427 eloop.signaled++;
428 for (i = 0; i < eloop.signal_count; i++) {
429 if (eloop.signals[i].sig == sig) {
430 eloop.signals[i].signaled++;
442 if (eloop.signaled == 0) in eloop_process_pending_signals()
444 eloop.signaled = 0; in eloop_process_pending_signals()
446 if (eloop.pending_terminate) { in eloop_process_pending_signals()
447 eloop.pending_terminate = 0; in eloop_process_pending_signals()
450 for (i = 0; i < eloop.signal_count; i++) { in eloop_process_pending_signals()
451 if (eloop.signals[i].signaled) { in eloop_process_pending_signals()
452 eloop.signals[i].signaled = 0; in eloop_process_pending_signals()
453 eloop.signals[i].handler(eloop.signals[i].sig, in eloop_process_pending_signals()
454 eloop.signals[i].user_data); in eloop_process_pending_signals()
458 if (eloop.term_signal.signaled) { in eloop_process_pending_signals()
459 eloop.term_signal.signaled = 0; in eloop_process_pending_signals()
460 eloop.term_signal.handler(eloop.term_signal.sig, in eloop_process_pending_signals()
461 eloop.term_signal.user_data); in eloop_process_pending_signals()
471 tmp = os_realloc_array(eloop.signals, eloop.signal_count + 1, in eloop_register_signal()
476 tmp[eloop.signal_count].sig = sig; in eloop_register_signal()
477 tmp[eloop.signal_count].user_data = user_data; in eloop_register_signal()
478 tmp[eloop.signal_count].handler = handler; in eloop_register_signal()
479 tmp[eloop.signal_count].signaled = 0; in eloop_register_signal()
480 eloop.signal_count++; in eloop_register_signal()
481 eloop.signals = tmp; in eloop_register_signal()
495 eloop.signaled++; in eloop_handle_console_ctrl()
496 eloop.term_signal.signaled++; in eloop_handle_console_ctrl()
497 SetEvent(eloop.term_event); in eloop_handle_console_ctrl()
518 eloop.term_signal.handler = handler; in eloop_register_signal_terminate()
519 eloop.term_signal.user_data = user_data; in eloop_register_signal_terminate()
539 while (!eloop.terminate && in eloop_run()
540 (!dl_list_empty(&eloop.timeout) || eloop.reader_count > 0 || in eloop_run()
541 eloop.event_count > 0)) { in eloop_run()
544 timeout = dl_list_first(&eloop.timeout, struct eloop_timeout, in eloop_run()
553 for (i = 0; i < eloop.event_count; i++) in eloop_run()
554 eloop.handles[count++] = eloop.events[i].event; in eloop_run()
556 for (i = 0; i < eloop.reader_count; i++) in eloop_run()
557 eloop.handles[count++] = eloop.readers[i].event; in eloop_run()
559 if (eloop.term_event) in eloop_run()
560 eloop.handles[count++] = eloop.term_event; in eloop_run()
574 ret = WaitForMultipleObjects(count, eloop.handles, FALSE, in eloop_run()
577 ret = WaitForMultipleObjectsEx(count, eloop.handles, FALSE, in eloop_run()
585 timeout = dl_list_first(&eloop.timeout, struct eloop_timeout, in eloop_run()
616 ret < WAIT_OBJECT_0 + eloop.event_count) { in eloop_run()
617 eloop.events[ret].handler( in eloop_run()
618 eloop.events[ret].eloop_data, in eloop_run()
619 eloop.events[ret].user_data); in eloop_run()
620 ret = WaitForMultipleObjects(eloop.event_count, in eloop_run()
621 eloop.handles, FALSE, 0); in eloop_run()
624 eloop.reader_table_changed = 0; in eloop_run()
625 for (i = 0; i < eloop.reader_count; i++) { in eloop_run()
627 if (WSAEnumNetworkEvents(eloop.readers[i].sock, in eloop_run()
628 eloop.readers[i].event, in eloop_run()
631 eloop.readers[i].handler( in eloop_run()
632 eloop.readers[i].sock, in eloop_run()
633 eloop.readers[i].eloop_data, in eloop_run()
634 eloop.readers[i].user_data); in eloop_run()
635 if (eloop.reader_table_changed) in eloop_run()
645 eloop.terminate = 1; in eloop_terminate()
646 SetEvent(eloop.term_event); in eloop_terminate()
654 dl_list_for_each_safe(timeout, prev, &eloop.timeout, in eloop_destroy()
658 os_free(eloop.readers); in eloop_destroy()
659 os_free(eloop.signals); in eloop_destroy()
660 if (eloop.term_event) in eloop_destroy()
661 CloseHandle(eloop.term_event); in eloop_destroy()
662 os_free(eloop.handles); in eloop_destroy()
663 eloop.handles = NULL; in eloop_destroy()
664 os_free(eloop.events); in eloop_destroy()
665 eloop.events = NULL; in eloop_destroy()
671 return eloop.terminate; in eloop_terminated()