Lines Matching refs:loop

125 static void handler_execute(esp_event_loop_instance_t* loop, esp_event_handler_node_t *handler, esp…  in handler_execute()  argument
127 …xt %p on loop %p", post.base, post.id, handler->handler_ctx->handler, &handler->handler_ctx, loop); in handler_execute()
153 xSemaphoreTake(loop->profiling_mutex, portMAX_DELAY); in handler_execute()
158 xSemaphoreGive(loop->profiling_mutex); in handler_execute()
460 esp_event_loop_instance_t* loop; in esp_event_loop_create() local
463 loop = calloc(1, sizeof(*loop)); in esp_event_loop_create()
464 if (loop == NULL) { in esp_event_loop_create()
469 loop->queue = xQueueCreate(event_loop_args->queue_size , sizeof(esp_event_post_instance_t)); in esp_event_loop_create()
470 if (loop->queue == NULL) { in esp_event_loop_create()
475 loop->mutex = xSemaphoreCreateRecursiveMutex(); in esp_event_loop_create()
476 if (loop->mutex == NULL) { in esp_event_loop_create()
482 loop->profiling_mutex = xSemaphoreCreateMutex(); in esp_event_loop_create()
483 if (loop->profiling_mutex == NULL) { in esp_event_loop_create()
489 SLIST_INIT(&(loop->loop_nodes)); in esp_event_loop_create()
494 event_loop_args->task_stack_size, (void*) loop, in esp_event_loop_create()
495 event_loop_args->task_priority, &(loop->task), event_loop_args->task_core_id); in esp_event_loop_create()
503 loop->name = event_loop_args->task_name; in esp_event_loop_create()
505 ESP_LOGD(TAG, "created task for loop %p", loop); in esp_event_loop_create()
507 loop->name = ""; in esp_event_loop_create()
508 loop->task = NULL; in esp_event_loop_create()
511 loop->running_task = NULL; in esp_event_loop_create()
515 SLIST_INSERT_HEAD(&s_event_loops, loop, next); in esp_event_loop_create()
519 *event_loop = (esp_event_loop_handle_t) loop; in esp_event_loop_create()
521 ESP_LOGD(TAG, "created event loop %p", loop); in esp_event_loop_create()
526 if (loop->queue != NULL) { in esp_event_loop_create()
527 vQueueDelete(loop->queue); in esp_event_loop_create()
530 if (loop->mutex != NULL) { in esp_event_loop_create()
531 vSemaphoreDelete(loop->mutex); in esp_event_loop_create()
535 if (loop->profiling_mutex != NULL) { in esp_event_loop_create()
536 vSemaphoreDelete(loop->profiling_mutex); in esp_event_loop_create()
540 free(loop); in esp_event_loop_create()
555 esp_event_loop_instance_t* loop = (esp_event_loop_instance_t*) event_loop; in esp_event_loop_run() local
566 while(xQueueReceive(loop->queue, &post, ticks_to_run) == pdTRUE) { in esp_event_loop_run()
568 xSemaphoreTakeRecursive(loop->mutex, portMAX_DELAY); in esp_event_loop_run()
570 loop->running_task = xTaskGetCurrentTaskHandle(); in esp_event_loop_run()
579 SLIST_FOREACH_SAFE(loop_node, &(loop->loop_nodes), next, temp_node) { in esp_event_loop_run()
582 handler_execute(loop, handler, post); in esp_event_loop_run()
590 handler_execute(loop, handler, post); in esp_event_loop_run()
598 handler_execute(loop, handler, post); in esp_event_loop_run()
619 xSemaphoreGiveRecursive(loop->mutex); in esp_event_loop_run()
626 loop->running_task = NULL; in esp_event_loop_run()
628 xSemaphoreGiveRecursive(loop->mutex); in esp_event_loop_run()
643 esp_event_loop_instance_t* loop = (esp_event_loop_instance_t*) event_loop; in esp_event_loop_delete() local
644 SemaphoreHandle_t loop_mutex = loop->mutex; in esp_event_loop_delete()
646 SemaphoreHandle_t loop_profiling_mutex = loop->profiling_mutex; in esp_event_loop_delete()
649 xSemaphoreTakeRecursive(loop->mutex, portMAX_DELAY); in esp_event_loop_delete()
652 xSemaphoreTake(loop->profiling_mutex, portMAX_DELAY); in esp_event_loop_delete()
654 SLIST_REMOVE(&s_event_loops, loop, esp_event_loop_instance, next); in esp_event_loop_delete()
659 if (loop->task != NULL) { in esp_event_loop_delete()
660 vTaskDelete(loop->task); in esp_event_loop_delete()
665 SLIST_FOREACH_SAFE(it, &(loop->loop_nodes), next, temp) { in esp_event_loop_delete()
667 SLIST_REMOVE(&(loop->loop_nodes), it, esp_event_loop_node, next); in esp_event_loop_delete()
673 while(xQueueReceive(loop->queue, &post, 0) == pdTRUE) { in esp_event_loop_delete()
678 vQueueDelete(loop->queue); in esp_event_loop_delete()
679 free(loop); in esp_event_loop_delete()
705 esp_event_loop_instance_t* loop = (esp_event_loop_instance_t*) event_loop; in esp_event_handler_register_with_internal() local
713 xSemaphoreTakeRecursive(loop->mutex, portMAX_DELAY); in esp_event_handler_register_with_internal()
717 SLIST_FOREACH(loop_node, &(loop->loop_nodes), next) { in esp_event_handler_register_with_internal()
740 SLIST_INSERT_HEAD(&(loop->loop_nodes), loop_node, next); in esp_event_handler_register_with_internal()
754 xSemaphoreGiveRecursive(loop->mutex); in esp_event_handler_register_with_internal()
786 esp_event_loop_instance_t* loop = (esp_event_loop_instance_t*) event_loop; in esp_event_handler_unregister_with_internal() local
788 xSemaphoreTakeRecursive(loop->mutex, portMAX_DELAY); in esp_event_handler_unregister_with_internal()
792 SLIST_FOREACH_SAFE(it, &(loop->loop_nodes), next, temp) { in esp_event_handler_unregister_with_internal()
796 SLIST_REMOVE(&(loop->loop_nodes), it, esp_event_loop_node, next); in esp_event_handler_unregister_with_internal()
802 xSemaphoreGiveRecursive(loop->mutex); in esp_event_handler_unregister_with_internal()
834 esp_event_loop_instance_t* loop = (esp_event_loop_instance_t*) event_loop; in esp_event_post_to() local
863 if (loop->task == NULL) { in esp_event_post_to()
865 result = xSemaphoreTakeRecursive(loop->mutex, ticks_to_wait); in esp_event_post_to()
868 if (loop->running_task != xTaskGetCurrentTaskHandle()) { in esp_event_post_to()
869 xSemaphoreGiveRecursive(loop->mutex); in esp_event_post_to()
870 result = xQueueSendToBack(loop->queue, &post, ticks_to_wait); in esp_event_post_to()
872 xSemaphoreGiveRecursive(loop->mutex); in esp_event_post_to()
873 result = xQueueSendToBack(loop->queue, &post, 0); in esp_event_post_to()
878 if (loop->task != xTaskGetCurrentTaskHandle()) { in esp_event_post_to()
879 result = xQueueSendToBack(loop->queue, &post, ticks_to_wait); in esp_event_post_to()
881 result = xQueueSendToBack(loop->queue, &post, 0); in esp_event_post_to()
889 atomic_fetch_add(&loop->events_dropped, 1); in esp_event_post_to()
895 atomic_fetch_add(&loop->events_recieved, 1); in esp_event_post_to()
911 esp_event_loop_instance_t* loop = (esp_event_loop_instance_t*) event_loop; in esp_event_isr_post_to() local
931 result = xQueueSendToBackFromISR(loop->queue, &post, task_unblocked); in esp_event_isr_post_to()
937 atomic_fetch_add(&loop->events_dropped, 1); in esp_event_isr_post_to()
943 atomic_fetch_add(&loop->events_recieved, 1); in esp_event_isr_post_to()