Branch data Line data Source code
# 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/system.h> # 9 : : #include <util/threadnames.h> # 10 : : # 11 : : #include <exception> # 12 : : # 13 : : void util::TraceThread(const char* thread_name, std::function<void()> thread_func) # 14 : 3973 : { # 15 : 3973 : util::ThreadRename(thread_name); # 16 : 3973 : try { # 17 : 3973 : LogPrintf("%s thread start\n", thread_name); # 18 : 3973 : thread_func(); # 19 : 3973 : LogPrintf("%s thread exit\n", thread_name); # 20 : 3973 : } catch (const std::exception& e) { # 21 : 0 : PrintExceptionContinue(&e, thread_name); # 22 : 0 : throw; # 23 : 0 : } catch (...) { # 24 : 0 : PrintExceptionContinue(nullptr, thread_name); # 25 : 0 : throw; # 26 : 0 : } # 27 : 3973 : }