1#include <xrpl/beast/core/CurrentThreadName.h>
2#include <xrpl/beast/utility/instrumentation.h>
18#if DEBUG && BOOST_COMP_MSVC
25 struct THREADNAME_INFO
37 ni.szName = name.
data();
38 ni.dwThreadID = GetCurrentThreadId();
42#pragma warning(disable : 6320 6322)
45 RaiseException(0x406d1388, 0,
sizeof(ni) /
sizeof(ULONG_PTR), (ULONG_PTR*)&ni);
47 __except (EXCEPTION_CONTINUE_EXECUTION)
65 pthread_setname_np(name.
data());
82 char boundedName[maxThreadNameLength + 1];
83 std::snprintf(boundedName,
sizeof(boundedName),
"%.*s",
static_cast<int>(maxThreadNameLength), name.
data());
85 pthread_setname_np(pthread_self(), boundedName);
87#ifdef TRUNCATED_THREAD_NAME_LOGS
88 if (name.
size() > maxThreadNameLength)
90 std::cerr <<
"WARNING: Thread name \"" << name <<
"\" (length " << name.
size() <<
") exceeds maximum of "
91 << maxThreadNameLength <<
" characters on Linux.\n";
95 "beast::detail::setCurrentThreadNameImpl : Thread name exceeds "
96 "maximum length for Linux");
120 detail::setCurrentThreadNameImpl(name);
thread_local std::string threadName
void setCurrentThreadName(std::string_view newThreadName)
Changes the name of the caller thread.
std::string getCurrentThreadName()
Returns the name of the caller thread.