blob: d742c8c585f2f74176dadf870cfcb3a35e610308 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#pragma once
#include <util/generic/strbuf.h>
#include <util/stream/str.h>
#include <util/system/execpath.h>
#include <util/system/thread.h>
#include <util/system/thread.h>
#include <time.h>
inline void SetCurrentThreadName(const TString& name,
const ui32 maxCharsFromProcessName = 8) {
#if defined(_linux_)
// linux limits threadname by 15 + \0
TStringBuf procName(GetExecPath());
procName = procName.RNextTok('/');
procName = procName.SubStr(0, maxCharsFromProcessName);
TStringStream linuxName;
linuxName << procName << "." << name;
TThread::SetCurrentThreadName(linuxName.Str().data());
#else
Y_UNUSED(maxCharsFromProcessName);
TThread::SetCurrentThreadName(name.data());
#endif
}
|