Changeset View
Changeset View
Standalone View
Standalone View
src/util/system.h
Show All 15 Lines | |||||
#include <attributes.h> | #include <attributes.h> | ||||
#include <compat.h> | #include <compat.h> | ||||
#include <compat/assumptions.h> | #include <compat/assumptions.h> | ||||
#include <fs.h> | #include <fs.h> | ||||
#include <logging.h> | #include <logging.h> | ||||
#include <sync.h> | #include <sync.h> | ||||
#include <tinyformat.h> | #include <tinyformat.h> | ||||
#include <util/threadnames.h> | |||||
#include <util/time.h> | #include <util/time.h> | ||||
#include <boost/thread/condition_variable.hpp> // for boost::thread_interrupted | #include <boost/thread/condition_variable.hpp> // for boost::thread_interrupted | ||||
#include <atomic> | #include <atomic> | ||||
#include <cstdint> | #include <cstdint> | ||||
#include <exception> | #include <exception> | ||||
#include <map> | #include <map> | ||||
▲ Show 20 Lines • Show All 296 Lines • ▼ Show 20 Lines | |||||
/** | /** | ||||
* Return the number of physical cores available on the current system. | * Return the number of physical cores available on the current system. | ||||
* @note This does not count virtual cores, such as those provided by | * @note This does not count virtual cores, such as those provided by | ||||
* HyperThreading when boost is newer than 1.56. | * HyperThreading when boost is newer than 1.56. | ||||
*/ | */ | ||||
int GetNumCores(); | int GetNumCores(); | ||||
void RenameThread(const char *name); | |||||
/** | /** | ||||
* .. and a wrapper that just calls func once | * .. and a wrapper that just calls func once | ||||
*/ | */ | ||||
template <typename Callable> void TraceThread(const char *name, Callable func) { | template <typename Callable> void TraceThread(const char *name, Callable func) { | ||||
std::string s = strprintf("bitcoin-%s", name); | util::ThreadRename(name); | ||||
RenameThread(s.c_str()); | |||||
try { | try { | ||||
LogPrintf("%s thread start\n", name); | LogPrintf("%s thread start\n", name); | ||||
func(); | func(); | ||||
LogPrintf("%s thread exit\n", name); | LogPrintf("%s thread exit\n", name); | ||||
} catch (const boost::thread_interrupted &) { | } catch (const boost::thread_interrupted &) { | ||||
LogPrintf("%s thread interrupt\n", name); | LogPrintf("%s thread interrupt\n", name); | ||||
throw; | throw; | ||||
} catch (const std::exception &e) { | } catch (const std::exception &e) { | ||||
▲ Show 20 Lines • Show All 48 Lines • Show Last 20 Lines |