5#include <bitcoin-build-config.h>
14#if (defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__))
16#include <pthread_np.h>
19#if __has_include(<sys/prctl.h>)
23#ifdef HAVE_SETTHREADDESCRIPTION
31#if defined(PR_SET_NAME)
33 ::prctl(PR_SET_NAME,
name, 0, 0, 0);
34#elif (defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__))
35 pthread_set_name_np(pthread_self(),
name);
36#elif defined(__APPLE__)
37 pthread_setname_np(
name);
38#elif defined(HAVE_SETTHREADDESCRIPTION)
41 const std::wstring wname{
name,
name + std::strlen(
name)};
42 ::SetThreadDescription(::GetCurrentThread(), wname.c_str());
#define Assume(val)
Assume is the identity function.
void ThreadRename(const std::string &)
Rename a thread both in terms of an internal (in-memory) name as well as its system thread name.
std::string ThreadGetInternalName()
Get the thread's internal (in-memory) name; used e.g.
void ThreadSetInternalName(const std::string &)
Set the internal (in-memory) name of the current thread only.
static thread_local char g_thread_name[128]
The name of the thread.
static void SetInternalName(const std::string &name)
Set the in-memory internal name for this thread.
static void SetThreadName(const char *name)
Set the thread's name at the process level.