Bitcoin Core  27.99.0
P2P Digital Currency
Functions | Variables
threadnames.cpp File Reference
#include <config/bitcoin-config.h>
#include <cstring>
#include <string>
#include <thread>
#include <utility>
#include <util/threadnames.h>
Include dependency graph for threadnames.cpp:

Go to the source code of this file.

Functions

static void SetThreadName (const char *name)
 Set the thread's name at the process level. More...
 
static void SetInternalName (const std::string &name)
 Set the in-memory internal name for this thread. More...
 

Variables

static thread_local char g_thread_name [128] {'\0'}
 The name of the thread. More...
 

Function Documentation

◆ SetInternalName()

static void SetInternalName ( const std::string &  name)
static

Set the in-memory internal name for this thread.

Does not affect the process name.

Definition at line 50 of file threadnames.cpp.

Here is the caller graph for this function:

◆ SetThreadName()

static void SetThreadName ( const char *  name)
static

Set the thread's name at the process level.

Does not affect the internal name.

Definition at line 25 of file threadnames.cpp.

Here is the caller graph for this function:

Variable Documentation

◆ g_thread_name

thread_local char g_thread_name[128] {'\0'}
static

The name of the thread.

We use char array instead of std::string to avoid complications with running a destructor when the thread exits. Avoid adding other thread_local variables.

See also
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=278701

Definition at line 46 of file threadnames.cpp.