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#ifndef BEAST_CORE_CURRENT_THREAD_NAME_H_INCLUDED
6#define BEAST_CORE_CURRENT_THREAD_NAME_H_INCLUDED
7
8#include <boost/predef.h>
9
10#include <string>
11#include <string_view>
12
13namespace beast {
14
18void
20
21#if BOOST_OS_LINUX
22
23// On Linux, thread names are limited to 16 bytes including the null terminator.
24// Maximum number of characters is therefore 15.
25constexpr std::size_t maxThreadNameLength = 15;
26
34template <std::size_t N>
35void
36setCurrentThreadName(char const (&newThreadName)[N])
37{
38 static_assert(
39 N <= maxThreadNameLength + 1,
40 "Thread name cannot exceed 15 characters");
41
42 setCurrentThreadName(std::string_view(newThreadName, N - 1));
43}
44#endif
45
56
57} // namespace beast
58
59#endif
void setCurrentThreadName(std::string_view newThreadName)
Changes the name of the caller thread.
std::string getCurrentThreadName()
Returns the name of the caller thread.