xrpld
Loading...
Searching...
No Matches
CurrentThreadName.h
1// Portions of this file are from JUCE (http://www.juce.com).
2// Copyright (c) 2013 - Raw Material Software Ltd.
3// Please visit http://www.juce.com
4
5#pragma once
6
7#include <boost/predef.h>
8
9#include <cstddef>
10#include <string>
11#include <string_view>
12
13namespace beast {
14
19void
20setCurrentThreadName(std::string_view newThreadName);
21
22#if BOOST_OS_LINUX
23
24// On Linux, thread names are limited to 16 bytes including the null terminator.
25// Maximum number of characters is therefore 15.
26constexpr std::size_t kMaxThreadNameLength = 15;
27
36template <std::size_t N>
37void
38setCurrentThreadName(char const (&newThreadName)[N])
39{
40 static_assert(N <= kMaxThreadNameLength + 1, "Thread name cannot exceed 15 characters");
41
42 setCurrentThreadName(std::string_view(newThreadName, N - 1));
43}
44#endif
45
55std::string
57
58} // namespace beast
void setCurrentThreadName(std::string_view newThreadName)
Changes the name of the caller thread.
std::string getCurrentThreadName()
Returns the name of the caller thread.