From c8a490821b3a77b8f070f0d1e20fe203a6526787 Mon Sep 17 00:00:00 2001 From: Hu Yueh-Wei Date: Mon, 25 Nov 2024 13:41:02 +0800 Subject: [PATCH] feat: set thread name for debugging purpose (#329) --- core/src/ten_runtime/app/app.c | 3 ++- core/src/ten_runtime/engine/internal/thread.c | 4 +++- core/src/ten_runtime/extension_thread/extension_thread.c | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/core/src/ten_runtime/app/app.c b/core/src/ten_runtime/app/app.c index 0741215ce..625163dc0 100644 --- a/core/src/ten_runtime/app/app.c +++ b/core/src/ten_runtime/app/app.c @@ -210,7 +210,8 @@ bool ten_app_run(ten_app_t *self, bool run_in_background, } if (run_in_background) { - ten_thread_create("app thread", ten_app_routine, self); + ten_thread_create(ten_string_get_raw_str(&self->uri), ten_app_routine, + self); ten_event_wait(self->belonging_thread_is_set, -1); } else { ten_app_routine(self); diff --git a/core/src/ten_runtime/engine/internal/thread.c b/core/src/ten_runtime/engine/internal/thread.c index ddbe01bee..f51f8c218 100644 --- a/core/src/ten_runtime/engine/internal/thread.c +++ b/core/src/ten_runtime/engine/internal/thread.c @@ -16,6 +16,7 @@ #include "ten_runtime/app/app.h" #include "ten_utils/io/runloop.h" #include "ten_utils/lib/event.h" +#include "ten_utils/lib/string.h" #include "ten_utils/lib/thread.h" #include "ten_utils/macro/check.h" #include "ten_utils/macro/mark.h" @@ -76,7 +77,8 @@ void ten_engine_create_its_own_thread(ten_engine_t *self) { self->belonging_thread_is_set = ten_event_create(0, 0); self->engine_thread_ready_for_migration = ten_event_create(0, 0); - ten_thread_create("engine thread", ten_engine_thread_main, self); + ten_thread_create(ten_string_get_raw_str(&self->graph_id), + ten_engine_thread_main, self); ten_event_set(self->belonging_thread_is_set); diff --git a/core/src/ten_runtime/extension_thread/extension_thread.c b/core/src/ten_runtime/extension_thread/extension_thread.c index 5cda3d146..ef1be758d 100644 --- a/core/src/ten_runtime/extension_thread/extension_thread.c +++ b/core/src/ten_runtime/extension_thread/extension_thread.c @@ -31,6 +31,7 @@ #include "ten_utils/lib/alloc.h" #include "ten_utils/lib/event.h" #include "ten_utils/lib/mutex.h" +#include "ten_utils/lib/string.h" #include "ten_utils/lib/thread.h" #include "ten_utils/macro/check.h" #include "ten_utils/macro/mark.h" @@ -282,7 +283,8 @@ void ten_extension_thread_start(ten_extension_thread_t *self) { ten_extension_thread_check_integrity(self, false), "Should not happen."); - ten_thread_create("extension thread", ten_extension_thread_main, self); + ten_thread_create(ten_string_get_raw_str(&self->extension_group->name), + ten_extension_thread_main, self); // The runloop of the extension_thread is created within the extension thread // itself, which introduces a time gap. If the engine (extension_context)