diff options
Diffstat (limited to 'src/zencore/thread.cpp')
| -rw-r--r-- | src/zencore/thread.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/zencore/thread.cpp b/src/zencore/thread.cpp index 394197b8e..ab7e6857a 100644 --- a/src/zencore/thread.cpp +++ b/src/zencore/thread.cpp @@ -80,8 +80,10 @@ SetNameInternal(DWORD thread_id, const char* name) void SetCurrentThreadName([[maybe_unused]] std::string_view ThreadName) { - std::string ThreadNameZ{ThreadName}; - const int ThreadId = GetCurrentThreadId(); + StringBuilder<256> ThreadNameZ; + ThreadNameZ << ThreadName; + const int ThreadId = GetCurrentThreadId(); + #if ZEN_WITH_TRACE trace::ThreadRegister(ThreadNameZ.c_str(), /* system id */ ThreadId, /* sort id */ 0); #endif // ZEN_WITH_TRACE @@ -93,7 +95,10 @@ SetCurrentThreadName([[maybe_unused]] std::string_view ThreadName) if (SetThreadDescriptionFunc) { - SetThreadDescriptionFunc(::GetCurrentThread(), Utf8ToWide(ThreadName).c_str()); + WideStringBuilder<256> ThreadNameW; + Utf8ToWide(ThreadName, ThreadNameW); + + SetThreadDescriptionFunc(::GetCurrentThread(), ThreadNameW.c_str()); } // The debugger needs to be around to catch the name in the exception. If @@ -348,8 +353,16 @@ NamedEvent::Close() if (flock(Fd, LOCK_EX | LOCK_NB) == 0) { - std::filesystem::path Name = PathFromHandle((void*)(intptr_t(Fd))); - unlink(Name.c_str()); + std::error_code Ec; + std::filesystem::path Name = PathFromHandle((void*)(intptr_t(Fd)), Ec); + if (Ec) + { + ZEN_WARN("Error reported on get file path from handle {} for named event unlink operation, reason '{}'", Fd, Ec.message()); + } + else + { + unlink(Name.c_str()); + } flock(Fd, LOCK_UN | LOCK_NB); close(Fd); |