aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/messagebus/actor/thread_extra.cpp
blob: 6472dd92f412bd4a59ecc972419179a0e5a453d1 (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
27
28
29
30
#include "thread_extra.h"

#include <util/stream/str.h>
#include <util/system/execpath.h>
#include <util/system/platform.h> 
#include <util/system/thread.h> 
 
namespace { 
#ifdef _linux_
    TString GetExecName() {
        TString execPath = GetExecPath();
        size_t lastSlash = execPath.find_last_of('/'); 
        if (lastSlash == TString::npos) {
            return execPath; 
        } else { 
            return execPath.substr(lastSlash + 1); 
        } 
    } 
#endif
} 
 
void SetCurrentThreadName(const char* name) {
#ifdef _linux_ 
    TStringStream linuxName; 
    linuxName << GetExecName() << "." << name; 
    TThread::SetCurrentThreadName(linuxName.Str().data());
#else 
    TThread::SetCurrentThreadName(name);
#endif 
}