mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
refactor: use std::string for thread names
This commit is contained in:
parent
29d540b7ad
commit
97f5b20c12
5 changed files with 10 additions and 7 deletions
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue