Page MenuHomePhabricator

D17706.id52804.diff
No OneTemporary

D17706.id52804.diff

diff --git a/src/util/exception.h b/src/util/exception.h
--- a/src/util/exception.h
+++ b/src/util/exception.h
@@ -9,6 +9,7 @@
#include <exception>
#include <string_view>
-void PrintExceptionContinue(const std::exception *pex, const char *pszThread);
+void PrintExceptionContinue(const std::exception *pex,
+ std::string_view thread_name);
#endif // BITCOIN_UTIL_EXCEPTION_H
diff --git a/src/util/exception.cpp b/src/util/exception.cpp
--- a/src/util/exception.cpp
+++ b/src/util/exception.cpp
@@ -18,7 +18,7 @@
#endif // WIN32
static std::string FormatException(const std::exception *pex,
- const char *pszThread) {
+ std::string_view thread_name) {
#ifdef WIN32
char pszModule[MAX_PATH] = "";
GetModuleFileNameA(nullptr, pszModule, sizeof(pszModule));
@@ -28,15 +28,16 @@
if (pex) {
return strprintf("EXCEPTION: %s \n%s \n%s in %s \n",
typeid(*pex).name(), pex->what(), pszModule,
- pszThread);
+ thread_name);
} else {
return strprintf("UNKNOWN EXCEPTION \n%s in %s \n",
- pszModule, pszThread);
+ pszModule, thread_name);
}
}
-void PrintExceptionContinue(const std::exception *pex, const char *pszThread) {
- std::string message = FormatException(pex, pszThread);
+void PrintExceptionContinue(const std::exception *pex,
+ std::string_view thread_name) {
+ std::string message = FormatException(pex, thread_name);
LogPrintf("\n\n************************\n%s\n", message);
tfm::format(std::cerr, "\n\n************************\n%s\n", message);
}
diff --git a/src/util/thread.h b/src/util/thread.h
--- a/src/util/thread.h
+++ b/src/util/thread.h
@@ -6,12 +6,14 @@
#define BITCOIN_UTIL_THREAD_H
#include <functional>
+#include <string>
namespace util {
/**
* A wrapper for do-something-once thread functions.
*/
-void TraceThread(const char *thread_name, std::function<void()> thread_func);
+void TraceThread(std::string_view thread_name,
+ std::function<void()> thread_func);
} // namespace util
diff --git a/src/util/thread.cpp b/src/util/thread.cpp
--- a/src/util/thread.cpp
+++ b/src/util/thread.cpp
@@ -9,10 +9,11 @@
#include <util/threadnames.h>
#include <exception>
+#include <string>
-void util::TraceThread(const char *thread_name,
+void util::TraceThread(std::string_view thread_name,
std::function<void()> thread_func) {
- util::ThreadRename(thread_name);
+ util::ThreadRename(std::string{thread_name});
try {
LogPrintf("%s thread start\n", thread_name);
thread_func();

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 1, 11:33 (5 h, 33 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5186096
Default Alt Text
D17706.id52804.diff (2 KB)

Event Timeline