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 : #include <functional> 13 : 14 621 : void util::TraceThread(const char* thread_name, std::function<void()> thread_func) 15 : { 16 621 : util::ThreadRename(thread_name); 17 : try { 18 621 : LogPrintf("%s thread start\n", thread_name); 19 621 : thread_func(); 20 621 : LogPrintf("%s thread exit\n", thread_name); 21 621 : } catch (...) { 22 0 : PrintExceptionContinue(std::current_exception(), thread_name); 23 0 : throw; 24 0 : } 25 621 : }