Skip to content

Commit e0f7515

Browse files
committed
Merge #12750: Replace boost::call_once with std::call_once
57dae3f 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
2 parents 2b1c50b + 57dae3f commit e0f7515

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/util.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,10 @@ instance_of_cinit;
159159
* the mutex).
160160
*/
161161

162-
static boost::once_flag debugPrintInitFlag = BOOST_ONCE_INIT;
162+
static std::once_flag debugPrintInitFlag;
163163

164164
/**
165-
* We use boost::call_once() to make sure mutexDebugLog and
165+
* We use std::call_once() to make sure mutexDebugLog and
166166
* vMsgsBeforeOpenLog are initialized in a thread-safe manner.
167167
*
168168
* NOTE: fileout, mutexDebugLog and sometimes vMsgsBeforeOpenLog
@@ -171,7 +171,7 @@ static boost::once_flag debugPrintInitFlag = BOOST_ONCE_INIT;
171171
* tested, explicit destruction of these objects can be implemented.
172172
*/
173173
static FILE* fileout = nullptr;
174-
static boost::mutex* mutexDebugLog = nullptr;
174+
static std::mutex* mutexDebugLog = nullptr;
175175
static std::list<std::string>* vMsgsBeforeOpenLog;
176176

177177
static int FileWriteStr(const std::string &str, FILE *fp)
@@ -182,7 +182,7 @@ static int FileWriteStr(const std::string &str, FILE *fp)
182182
static void DebugPrintInit()
183183
{
184184
assert(mutexDebugLog == nullptr);
185-
mutexDebugLog = new boost::mutex();
185+
mutexDebugLog = new std::mutex();
186186
vMsgsBeforeOpenLog = new std::list<std::string>;
187187
}
188188

@@ -194,8 +194,8 @@ fs::path GetDebugLogPath()
194194

195195
bool OpenDebugLog()
196196
{
197-
boost::call_once(&DebugPrintInit, debugPrintInitFlag);
198-
boost::mutex::scoped_lock scoped_lock(*mutexDebugLog);
197+
std::call_once(debugPrintInitFlag, &DebugPrintInit);
198+
std::lock_guard<std::mutex> scoped_lock(*mutexDebugLog);
199199

200200
assert(fileout == nullptr);
201201
assert(vMsgsBeforeOpenLog);
@@ -350,8 +350,8 @@ int LogPrintStr(const std::string &str)
350350
}
351351
else if (fPrintToDebugLog)
352352
{
353-
boost::call_once(&DebugPrintInit, debugPrintInitFlag);
354-
boost::mutex::scoped_lock scoped_lock(*mutexDebugLog);
353+
std::call_once(debugPrintInitFlag, &DebugPrintInit);
354+
std::lock_guard<std::mutex> scoped_lock(*mutexDebugLog);
355355

356356
// buffer if we haven't opened the log yet
357357
if (fileout == nullptr) {

0 commit comments

Comments
 (0)