diff options
author | stickies-v <stickies-v@protonmail.com> | 2022-08-31 16:30:35 +0100 |
---|---|---|
committer | stickies-v <stickies-v@protonmail.com> | 2022-09-13 19:07:39 +0100 |
commit | 97f5b20c12ca6ccf89d7720a5d41eaf4cda1b695 (patch) | |
tree | fee87877bc54e805480a708002716467e9a82652 | |
parent | 29d540b7ada890dd588c4825d40c27c5e6f20061 (diff) | |
download | bitcoin-97f5b20c12ca6ccf89d7720a5d41eaf4cda1b695.tar.xz |
refactor: use std::string for thread names
-rw-r--r-- | src/qt/guiutil.cpp | 2 | ||||
-rw-r--r-- | src/util/system.cpp | 4 | ||||
-rw-r--r-- | src/util/system.h | 2 | ||||
-rw-r--r-- | src/util/thread.cpp | 6 | ||||
-rw-r--r-- | src/util/thread.h | 3 |
5 files changed, 10 insertions, 7 deletions
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 5cc21dd40b..b9f0be41e3 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -982,7 +982,7 @@ void PrintSlotException( std::string description = sender->metaObject()->className(); description += "->"; description += receiver->metaObject()->className(); - PrintExceptionContinue(exception, description.c_str()); + PrintExceptionContinue(exception, description); } void ShowModalDialogAsynchronously(QDialog* dialog) diff --git a/src/util/system.cpp b/src/util/system.cpp index 1953a9f836..8864ae73c4 100644 --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -831,7 +831,7 @@ std::string HelpMessageOpt(const std::string &option, const std::string &message std::string("\n\n"); } -static std::string FormatException(const std::exception* pex, const char* pszThread) +static std::string FormatException(const std::exception* pex, std::string_view pszThread) { #ifdef WIN32 char pszModule[MAX_PATH] = ""; @@ -847,7 +847,7 @@ static std::string FormatException(const std::exception* pex, const char* pszThr "UNKNOWN EXCEPTION \n%s in %s \n", pszModule, pszThread); } -void PrintExceptionContinue(const std::exception* pex, const char* pszThread) +void PrintExceptionContinue(const std::exception* pex, std::string_view pszThread) { std::string message = FormatException(pex, pszThread); LogPrintf("\n\n************************\n%s\n", message); diff --git a/src/util/system.h b/src/util/system.h index 756e6642f2..5f80ca51fc 100644 --- a/src/util/system.h +++ b/src/util/system.h @@ -51,7 +51,7 @@ bool error(const char* fmt, const Args&... args) return false; } -void PrintExceptionContinue(const std::exception *pex, const char* pszThread); +void PrintExceptionContinue(const std::exception* pex, std::string_view pszThread); /** * Ensure file contents are fully committed to disk, using a platform-specific diff --git a/src/util/thread.cpp b/src/util/thread.cpp index f9f427ba20..ae98abdb3d 100644 --- a/src/util/thread.cpp +++ b/src/util/thread.cpp @@ -10,10 +10,12 @@ #include <exception> #include <functional> +#include <string> +#include <utility> -void util::TraceThread(const char* thread_name, std::function<void()> thread_func) +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(); diff --git a/src/util/thread.h b/src/util/thread.h index ca2eccc0c3..b80bf046a0 100644 --- a/src/util/thread.h +++ b/src/util/thread.h @@ -6,12 +6,13 @@ #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 |