From 734bdf4d955b7af31f1a438799183a5b42a556d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Fri, 6 Oct 2023 18:19:59 +0200 Subject: [PATCH] feat: make the thread name configurable --- thpool.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/thpool.c b/thpool.c index 59e2e55..716a487 100644 --- a/thpool.c +++ b/thpool.c @@ -40,6 +40,13 @@ #define err(str) #endif +#ifndef THPOOL_THREAD_NAME +#define THPOOL_THREAD_NAME thpool +#endif + +#define STRINGIFY(x) #x +#define TOSTRING(x) STRINGIFY(x) + static volatile int threads_keepalive; static volatile int threads_on_hold; @@ -324,7 +331,8 @@ static void* thread_do(struct thread* thread_p){ /* Set thread name for profiling and debugging */ char thread_name[16] = {0}; - snprintf(thread_name, 16, "thpool-%d", thread_p->id); + + snprintf(thread_name, 16, TOSTRING(THPOOL_THREAD_NAME) "-%d", thread_p->id); #if defined(__linux__) /* Use prctl instead to prevent using _GNU_SOURCE flag and implicit declaration */