feat: make the thread name configurable

This commit is contained in:
Kévin Dunglas 2023-10-06 18:19:59 +02:00
parent 3669b9bdf3
commit 734bdf4d95
No known key found for this signature in database
GPG Key ID: 4D04EBEF06AAF3A6
1 changed files with 9 additions and 1 deletions

View File

@ -40,6 +40,13 @@
#define err(str) #define err(str)
#endif #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_keepalive;
static volatile int threads_on_hold; 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 */ /* Set thread name for profiling and debugging */
char thread_name[16] = {0}; 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__) #if defined(__linux__)
/* Use prctl instead to prevent using _GNU_SOURCE flag and implicit declaration */ /* Use prctl instead to prevent using _GNU_SOURCE flag and implicit declaration */