diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2018-03-21 15:53:46 -0700 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2018-03-21 16:01:21 -0700 |
commit | e0f7515f5500968c86e5a9f4912d83d4abc5b2b9 (patch) | |
tree | ab7b606e08ce9a3629c5b7065974f869c5d0956f /src | |
parent | 2b1c50b9352ab1dc40b0f877db23c1fa4048fae3 (diff) | |
parent | 57dae3fc4a101ae3cd29c1b2881a61fc36b806de (diff) |
Merge #12750: Replace boost::call_once with std::call_once
57dae3fc4a Replace boost::call_once with std::call_once (donaloconnor)
Pull request description:
This replaces boost::call_once with the C++11 std::call_once. The aim is to remove unnecessary boost code.
Tested on Windows/MSVC
Tree-SHA512: 5e98ea6e5052fffeaf29f845f4ecf1078b38cbb27671c5b7b6167e7f074a391e10020445107979d9e220d029bc9464fb8b2ccb0bea664eeb7af59a789c988b10
Diffstat (limited to 'src')
-rw-r--r-- | src/util.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/util.cpp b/src/util.cpp index 94f829ad32..69ceefc8cd 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -159,10 +159,10 @@ instance_of_cinit; * the mutex). */ -static boost::once_flag debugPrintInitFlag = BOOST_ONCE_INIT; +static std::once_flag debugPrintInitFlag; /** - * We use boost::call_once() to make sure mutexDebugLog and + * We use std::call_once() to make sure mutexDebugLog and * vMsgsBeforeOpenLog are initialized in a thread-safe manner. * * NOTE: fileout, mutexDebugLog and sometimes vMsgsBeforeOpenLog @@ -171,7 +171,7 @@ static boost::once_flag debugPrintInitFlag = BOOST_ONCE_INIT; * tested, explicit destruction of these objects can be implemented. */ static FILE* fileout = nullptr; -static boost::mutex* mutexDebugLog = nullptr; +static std::mutex* mutexDebugLog = nullptr; static std::list<std::string>* vMsgsBeforeOpenLog; static int FileWriteStr(const std::string &str, FILE *fp) @@ -182,7 +182,7 @@ static int FileWriteStr(const std::string &str, FILE *fp) static void DebugPrintInit() { assert(mutexDebugLog == nullptr); - mutexDebugLog = new boost::mutex(); + mutexDebugLog = new std::mutex(); vMsgsBeforeOpenLog = new std::list<std::string>; } @@ -194,8 +194,8 @@ fs::path GetDebugLogPath() bool OpenDebugLog() { - boost::call_once(&DebugPrintInit, debugPrintInitFlag); - boost::mutex::scoped_lock scoped_lock(*mutexDebugLog); + std::call_once(debugPrintInitFlag, &DebugPrintInit); + std::lock_guard<std::mutex> scoped_lock(*mutexDebugLog); assert(fileout == nullptr); assert(vMsgsBeforeOpenLog); @@ -350,8 +350,8 @@ int LogPrintStr(const std::string &str) } else if (fPrintToDebugLog) { - boost::call_once(&DebugPrintInit, debugPrintInitFlag); - boost::mutex::scoped_lock scoped_lock(*mutexDebugLog); + std::call_once(debugPrintInitFlag, &DebugPrintInit); + std::lock_guard<std::mutex> scoped_lock(*mutexDebugLog); // buffer if we haven't opened the log yet if (fileout == nullptr) { |