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];
87 static_cast<int>(maxThreadNameLength),
90 pthread_setname_np(pthread_self(), boundedName);
92#ifdef TRUNCATED_THREAD_NAME_LOGS
93 if (name.
size() > maxThreadNameLength)
95 std::cerr <<
"WARNING: Thread name \"" << name <<
"\" (length " << name.
size()
96 <<
") exceeds maximum of " << maxThreadNameLength <<
" characters on Linux.\n";
100 "beast::detail::setCurrentThreadNameImpl : Thread name exceeds "
101 "maximum length for Linux");
125 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.