Skip to content

Commit

Permalink
feat: set thread name for debugging purpose (#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
halajohn authored Nov 25, 2024
1 parent 586eed2 commit c8a4908
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion core/src/ten_runtime/app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion core/src/ten_runtime/engine/internal/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);

Expand Down
4 changes: 3 additions & 1 deletion core/src/ten_runtime/extension_thread/extension_thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c8a4908

Please sign in to comment.