Bitcoin ABC
0.34.5
P2P Digital Currency
Loading...
Searching...
No Matches
src
util
thread.cpp
Go to the documentation of this file.
1
// Copyright (c) 2021 The Bitcoin Core developers
2
// Distributed under the MIT software license, see the accompanying
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5
#include <
util/thread.h
>
6
7
#include <
logging.h
>
8
#include <
util/exception.h
>
9
#include <
util/threadnames.h
>
10
11
#include <exception>
12
#include <string>
13
14
void
util::TraceThread
(std::string_view thread_name,
15
std::function<
void
()> thread_func) {
16
util::ThreadRename
(std::string{thread_name});
17
try
{
18
LogPrintf
(
"%s thread start\n"
, thread_name);
19
thread_func();
20
LogPrintf
(
"%s thread exit\n"
, thread_name);
21
}
catch
(
const
std::exception &e) {
22
PrintExceptionContinue
(&e, thread_name);
23
throw
;
24
}
catch
(...) {
25
PrintExceptionContinue
(
nullptr
, thread_name);
26
throw
;
27
}
28
}
PrintExceptionContinue
void PrintExceptionContinue(const std::exception *pex, std::string_view thread_name)
Definition
exception.cpp:38
exception.h
logging.h
LogPrintf
#define LogPrintf(...)
Definition
logging.h:424
util::TraceThread
void TraceThread(std::string_view thread_name, std::function< void()> thread_func)
A wrapper for do-something-once thread functions.
Definition
thread.cpp:14
util::ThreadRename
void ThreadRename(std::string &&)
Rename a thread both in terms of an internal (in-memory) name as well as its system thread name.
Definition
threadnames.cpp:48
thread.h
threadnames.h
Generated on Mon Nov 23 2026 16:26:18 for Bitcoin ABC by
1.9.8