5 #if defined(HAVE_CONFIG_H)
13 #if (defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__))
15 #include <pthread_np.h>
20 #ifdef HAVE_SYS_PRCTL_H
21 #include <sys/prctl.h>
28 #if defined(PR_SET_NAME)
30 ::prctl(PR_SET_NAME,
name, 0, 0, 0);
31 #elif (defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__))
32 pthread_set_name_np(pthread_self(),
name);
33 #elif defined(MAC_OSX)
34 pthread_setname_np(
name);
43 #if defined(HAVE_THREAD_LOCAL)
45 static thread_local std::string g_thread_name;
void ThreadSetInternalName(std::string &&)
Set the internal (in-memory) name of the current thread only.
const std::string & ThreadGetInternalName()
Get the thread's internal (in-memory) name; used e.g.
void ThreadRename(std::string &&)
Rename a thread both in terms of an internal (in-memory) name as well as its system thread name.
static void SetInternalName(std::string name)
static const std::string empty_string
static void SetThreadName(const char *name)
Set the thread's name at the process level.