aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/misc/thread_name.cpp
diff options
context:
space:
mode:
authoryuryalekseev <yuryalekseev@yandex-team.com>2023-06-05 15:35:22 +0300
committeryuryalekseev <yuryalekseev@yandex-team.com>2023-06-05 15:35:22 +0300
commit682f9f94f49c0edfd94cdf1aac97372918a2b894 (patch)
treef2fdd4b3316158e6ce7b06bf9fa33d79fca2e8c9 /library/cpp/yt/misc/thread_name.cpp
parent45c174f12cdc1defbcec3574d224d9d5be4e5b95 (diff)
downloadydb-682f9f94f49c0edfd94cdf1aac97372918a2b894.tar.gz
YT-17341: Use TThreadName instead of TString to store thread name in error.
Diffstat (limited to 'library/cpp/yt/misc/thread_name.cpp')
-rw-r--r--library/cpp/yt/misc/thread_name.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/library/cpp/yt/misc/thread_name.cpp b/library/cpp/yt/misc/thread_name.cpp
index 372e14462e..63ba1ee227 100644
--- a/library/cpp/yt/misc/thread_name.cpp
+++ b/library/cpp/yt/misc/thread_name.cpp
@@ -10,10 +10,18 @@ namespace NYT {
////////////////////////////////////////////////////////////////////////////////
-TString TThreadName::ToString() const
+TStringBuf TThreadName::ToStringBuf() const
{
// Buffer is zero terminated.
- return Buffer.data();
+ return TStringBuf(Buffer.data(), Length);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+TThreadName::TThreadName(const TString& name)
+{
+ Length = std::min<int>(TThreadName::BufferCapacity - 1, name.length());
+ ::memcpy(Buffer.data(), name.data(), Length);
}
////////////////////////////////////////////////////////////////////////////////