Skip to content

Commit

Permalink
Replace boost::call_once with std::call_once
Browse files Browse the repository at this point in the history
  • Loading branch information
donaloconnor authored and Bashkir committed Mar 2, 2019
1 parent 4d52bca commit 97221ba
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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>;
}

Expand All @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 97221ba

Please sign in to comment.