rippled
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 <string>
10#include <string_view>
11
12namespace beast {
13
17void
19
20#if BOOST_OS_LINUX
21
22// On Linux, thread names are limited to 16 bytes including the null terminator.
23// Maximum number of characters is therefore 15.
24constexpr std::size_t maxThreadNameLength = 15;
25
33template <std::size_t N>
34void
35setCurrentThreadName(char const (&newThreadName)[N])
36{
37 static_assert(N <= maxThreadNameLength + 1, "Thread name cannot exceed 15 characters");
38
39 setCurrentThreadName(std::string_view(newThreadName, N - 1));
40}
41#endif
42
53
54} // 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.