Lines Matching refs:event_loop

27 static void s_destroy(struct aws_event_loop *event_loop);
28 static int s_run(struct aws_event_loop *event_loop);
29 static int s_stop(struct aws_event_loop *event_loop);
30 static int s_wait_for_stop_completion(struct aws_event_loop *event_loop);
31 static void s_schedule_task_now(struct aws_event_loop *event_loop, struct aws_task *task);
32 static void s_schedule_task_future(struct aws_event_loop *event_loop, struct aws_task *task, uint64…
33 static void s_cancel_task(struct aws_event_loop *event_loop, struct aws_task *task);
35 struct aws_event_loop *event_loop,
40 static int s_unsubscribe_from_io_events(struct aws_event_loop *event_loop, struct aws_io_handle *ha…
42 static bool s_is_event_thread(struct aws_event_loop *event_loop);
101 struct aws_event_loop *event_loop; member
150 struct aws_event_loop *event_loop = aws_mem_acquire(alloc, sizeof(struct aws_event_loop)); in aws_event_loop_new_default_with_options() local
151 if (!event_loop) { in aws_event_loop_new_default_with_options()
155 …S_LOGF_INFO(AWS_LS_IO_EVENT_LOOP, "id=%p: Initializing edge-triggered kqueue", (void *)event_loop); in aws_event_loop_new_default_with_options()
158 int err = aws_event_loop_init_base(event_loop, alloc, options->clock); in aws_event_loop_new_default_with_options()
187 … AWS_LOGF_FATAL(AWS_LS_IO_EVENT_LOOP, "id=%p: Failed to open kqueue handle.", (void *)event_loop); in aws_event_loop_new_default_with_options()
195 … AWS_LOGF_FATAL(AWS_LS_IO_EVENT_LOOP, "id=%p: failed to open pipe handle.", (void *)event_loop); in aws_event_loop_new_default_with_options()
201 (void *)event_loop, in aws_event_loop_new_default_with_options()
226 …L(AWS_LS_IO_EVENT_LOOP, "id=%p: failed to create cross-thread signal kevent.", (void *)event_loop); in aws_event_loop_new_default_with_options()
251 event_loop->impl_data = impl; in aws_event_loop_new_default_with_options()
253 event_loop->vtable = &s_kqueue_vtable; in aws_event_loop_new_default_with_options()
256 return event_loop; in aws_event_loop_new_default_with_options()
286 aws_event_loop_clean_up_base(event_loop); in aws_event_loop_new_default_with_options()
289 aws_mem_release(alloc, event_loop); in aws_event_loop_new_default_with_options()
294 static void s_destroy(struct aws_event_loop *event_loop) { in s_destroy() argument
295 AWS_LOGF_INFO(AWS_LS_IO_EVENT_LOOP, "id=%p: destroying event_loop", (void *)event_loop); in s_destroy()
296 struct kqueue_loop *impl = event_loop->impl_data; in s_destroy()
299 s_stop(event_loop); in s_destroy()
300 int err = s_wait_for_stop_completion(event_loop); in s_destroy()
305 (void *)event_loop); in s_destroy()
352 aws_mem_release(event_loop->alloc, impl); in s_destroy()
353 aws_event_loop_clean_up_base(event_loop); in s_destroy()
354 aws_mem_release(event_loop->alloc, event_loop); in s_destroy()
357 static int s_run(struct aws_event_loop *event_loop) { in s_run() argument
358 struct kqueue_loop *impl = event_loop->impl_data; in s_run()
360 AWS_LOGF_INFO(AWS_LS_IO_EVENT_LOOP, "id=%p: starting event-loop thread.", (void *)event_loop); in s_run()
371 …aws_thread_launch(&impl->thread_created_on, s_event_thread_main, (void *)event_loop, &impl->thread… in s_run()
375 AWS_LOGF_FATAL(AWS_LS_IO_EVENT_LOOP, "id=%p: thread creation failed.", (void *)event_loop); in s_run()
387 void signal_cross_thread_data_changed(struct aws_event_loop *event_loop) { in signal_cross_thread_data_changed() argument
388 struct kqueue_loop *impl = event_loop->impl_data; in signal_cross_thread_data_changed()
393 (void *)event_loop); in signal_cross_thread_data_changed()
401 static int s_stop(struct aws_event_loop *event_loop) { in s_stop() argument
402 struct kqueue_loop *impl = event_loop->impl_data; in s_stop()
417 signal_cross_thread_data_changed(event_loop); in s_stop()
423 static int s_wait_for_stop_completion(struct aws_event_loop *event_loop) { in s_wait_for_stop_completion() argument
424 struct kqueue_loop *impl = event_loop->impl_data; in s_wait_for_stop_completion()
449 static void s_schedule_task_common(struct aws_event_loop *event_loop, struct aws_task *task, uint64… in s_schedule_task_common() argument
451 struct kqueue_loop *impl = event_loop->impl_data; in s_schedule_task_common()
454 if (s_is_event_thread(event_loop)) { in s_schedule_task_common()
458 (void *)event_loop, in s_schedule_task_common()
473 (void *)event_loop, in s_schedule_task_common()
493 signal_cross_thread_data_changed(event_loop); in s_schedule_task_common()
497 static void s_schedule_task_now(struct aws_event_loop *event_loop, struct aws_task *task) { in s_schedule_task_now() argument
498 s_schedule_task_common(event_loop, task, 0); /* Zero is used to denote "now" tasks */ in s_schedule_task_now()
501 static void s_schedule_task_future(struct aws_event_loop *event_loop, struct aws_task *task, uint64… in s_schedule_task_future() argument
502 s_schedule_task_common(event_loop, task, run_at_nanos); in s_schedule_task_future()
505 static void s_cancel_task(struct aws_event_loop *event_loop, struct aws_task *task) { in s_cancel_task() argument
506 struct kqueue_loop *kqueue_loop = event_loop->impl_data; in s_cancel_task()
507 …AWS_LOGF_TRACE(AWS_LS_IO_EVENT_LOOP, "id=%p: cancelling task %p", (void *)event_loop, (void *)task… in s_cancel_task()
515 struct aws_event_loop *event_loop = handle_data->event_loop; in s_subscribe_task() local
516 struct kqueue_loop *impl = handle_data->event_loop->impl_data; in s_subscribe_task()
525 …AWS_LS_IO_EVENT_LOOP, "id=%p: subscribing to events on fd %d", (void *)event_loop, handle_data->ow… in s_subscribe_task()
594 (void *)event_loop, in s_subscribe_task()
612 …handle_data->on_event(event_loop, handle_data->owner, AWS_IO_EVENT_TYPE_ERROR, handle_data->on_eve… in s_subscribe_task()
616 struct aws_event_loop *event_loop, in s_subscribe_to_io_events() argument
622 AWS_ASSERT(event_loop); in s_subscribe_to_io_events()
629 …struct handle_data *handle_data = aws_mem_calloc(event_loop->alloc, 1, sizeof(struct handle_data)); in s_subscribe_to_io_events()
635 handle_data->event_loop = event_loop; in s_subscribe_to_io_events()
652 s_schedule_task_now(event_loop, &handle_data->subscribe_task); in s_subscribe_to_io_events()
659 struct kqueue_loop *impl = handle_data->event_loop->impl_data; in s_free_io_event_resources()
663 aws_mem_release(handle_data->event_loop->alloc, handle_data); in s_free_io_event_resources()
674 static int s_unsubscribe_from_io_events(struct aws_event_loop *event_loop, struct aws_io_handle *ha… in s_unsubscribe_from_io_events() argument
676 …AWS_LS_IO_EVENT_LOOP, "id=%p: un-subscribing from events on fd %d", (void *)event_loop, handle->da… in s_unsubscribe_from_io_events()
679 struct kqueue_loop *impl = event_loop->impl_data; in s_unsubscribe_from_io_events()
681 AWS_ASSERT(event_loop == handle_data->event_loop); in s_unsubscribe_from_io_events()
719 aws_event_loop_schedule_task_now(event_loop, &handle_data->cleanup_task); in s_unsubscribe_from_io_events()
727 static bool s_is_event_thread(struct aws_event_loop *event_loop) { in s_is_event_thread() argument
728 struct kqueue_loop *impl = event_loop->impl_data; in s_is_event_thread()
736 static void s_process_tasks_to_schedule(struct aws_event_loop *event_loop, struct aws_linked_list *… in s_process_tasks_to_schedule() argument
737 struct kqueue_loop *impl = event_loop->impl_data; in s_process_tasks_to_schedule()
738 … AWS_LOGF_TRACE(AWS_LS_IO_EVENT_LOOP, "id=%p: processing cross-thread tasks", (void *)event_loop); in s_process_tasks_to_schedule()
747 (void *)event_loop, in s_process_tasks_to_schedule()
758 static void s_process_cross_thread_data(struct aws_event_loop *event_loop) { in s_process_cross_thread_data() argument
759 struct kqueue_loop *impl = event_loop->impl_data; in s_process_cross_thread_data()
761 …TRACE(AWS_LS_IO_EVENT_LOOP, "id=%p: notified of cross-thread data to process", (void *)event_loop); in s_process_cross_thread_data()
782 s_process_tasks_to_schedule(event_loop, &tasks_to_schedule); in s_process_cross_thread_data()
812 struct aws_event_loop *event_loop = user_data; in s_event_thread_main() local
813 AWS_LOGF_INFO(AWS_LS_IO_EVENT_LOOP, "id=%p: main loop started", (void *)event_loop); in s_event_thread_main()
814 struct kqueue_loop *impl = event_loop->impl_data; in s_event_thread_main()
838 (void *)event_loop, in s_event_thread_main()
849 (void *)event_loop, in s_event_thread_main()
857 aws_event_loop_register_tick_start(event_loop); in s_event_thread_main()
859 …AWS_LS_IO_EVENT_LOOP, "id=%p: wake up with %d events to process.", (void *)event_loop, num_kevents… in s_event_thread_main()
909 (void *)event_loop, in s_event_thread_main()
912event_loop, handle_data->owner, handle_data->events_this_loop, handle_data->on_event_user_data); in s_event_thread_main()
920 s_process_cross_thread_data(event_loop); in s_event_thread_main()
925event_loop->clock(&now_ns); /* If clock fails, now_ns will be 0 and tasks scheduled for a specific… in s_event_thread_main()
927 AWS_LOGF_TRACE(AWS_LS_IO_EVENT_LOOP, "id=%p: running scheduled tasks.", (void *)event_loop); in s_event_thread_main()
934 int err = event_loop->clock(&now_ns); in s_event_thread_main()
947 …AWS_LS_IO_EVENT_LOOP, "id=%p: no more scheduled tasks using default timeout.", (void *)event_loop); in s_event_thread_main()
967 (void *)event_loop, in s_event_thread_main()
975 aws_event_loop_register_tick_end(event_loop); in s_event_thread_main()
978 AWS_LOGF_INFO(AWS_LS_IO_EVENT_LOOP, "id=%p: exiting main loop", (void *)event_loop); in s_event_thread_main()