Bitcoin Core
31.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
src
util
thread.cpp
Go to the documentation of this file.
1
// Copyright (c) 2021-present 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 <
util/exception.h
>
8
#include <
util/log.h
>
9
#include <
util/threadnames.h
>
10
11
#include <exception>
12
#include <functional>
13
#include <string>
14
#include <utility>
15
16
void
util::TraceThread
(std::string_view thread_name, std::function<
void
()> thread_func)
17
{
18
util::ThreadRename
(std::string{thread_name});
19
try
{
20
LogInfo
(
"%s thread start"
, thread_name);
21
thread_func();
22
LogInfo
(
"%s thread exit"
, thread_name);
23
}
catch
(
const
std::exception& e) {
24
PrintExceptionContinue
(&e, thread_name);
25
throw
;
26
}
catch
(...) {
27
PrintExceptionContinue
(
nullptr
, thread_name);
28
throw
;
29
}
30
}
PrintExceptionContinue
void PrintExceptionContinue(const std::exception *pex, std::string_view thread_name)
Definition
exception.cpp:36
log.h
LogInfo
#define LogInfo(...)
Definition
log.h:95
util::ThreadRename
void ThreadRename(const std::string &)
Definition
threadnames.cpp:55
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:16
thread.h
threadnames.h
exception.h
Generated on
for Bitcoin Core by
1.16.1