Skip to content

Commit dfb75ae

Browse files
committed
refactor: Rename LockGuard to StdLockGuard for consistency with StdMutex
1 parent 79be487 commit dfb75ae

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/logging.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static int FileWriteStr(const std::string &str, FILE *fp)
4141

4242
bool BCLog::Logger::StartLogging()
4343
{
44-
LockGuard scoped_lock(m_cs);
44+
StdLockGuard scoped_lock(m_cs);
4545

4646
assert(m_buffering);
4747
assert(m_fileout == nullptr);
@@ -80,7 +80,7 @@ bool BCLog::Logger::StartLogging()
8080

8181
void BCLog::Logger::DisconnectTestLogger()
8282
{
83-
LockGuard scoped_lock(m_cs);
83+
StdLockGuard scoped_lock(m_cs);
8484
m_buffering = true;
8585
if (m_fileout != nullptr) fclose(m_fileout);
8686
m_fileout = nullptr;
@@ -246,7 +246,7 @@ namespace BCLog {
246246

247247
void BCLog::Logger::LogPrintStr(const std::string& str)
248248
{
249-
LockGuard scoped_lock(m_cs);
249+
StdLockGuard scoped_lock(m_cs);
250250
std::string str_prefixed = LogEscapeMessage(str);
251251

252252
if (m_log_threadnames && m_started_new_line) {

src/logging.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -100,22 +100,22 @@ namespace BCLog {
100100
/** Returns whether logs will be written to any output */
101101
bool Enabled() const
102102
{
103-
LockGuard scoped_lock(m_cs);
103+
StdLockGuard scoped_lock(m_cs);
104104
return m_buffering || m_print_to_console || m_print_to_file || !m_print_callbacks.empty();
105105
}
106106

107107
/** Connect a slot to the print signal and return the connection */
108108
std::list<std::function<void(const std::string&)>>::iterator PushBackCallback(std::function<void(const std::string&)> fun)
109109
{
110-
LockGuard scoped_lock(m_cs);
110+
StdLockGuard scoped_lock(m_cs);
111111
m_print_callbacks.push_back(std::move(fun));
112112
return --m_print_callbacks.end();
113113
}
114114

115115
/** Delete a connection */
116116
void DeleteCallback(std::list<std::function<void(const std::string&)>>::iterator it)
117117
{
118-
LockGuard scoped_lock(m_cs);
118+
StdLockGuard scoped_lock(m_cs);
119119
m_print_callbacks.erase(it);
120120
}
121121

src/threadsafety.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ class LOCKABLE StdMutex : public std::mutex
6262
{
6363
};
6464

65-
// LockGuard provides an annotated version of lock_guard for us
66-
// should only be used when sync.h Mutex/LOCK/etc aren't usable
67-
class SCOPED_LOCKABLE LockGuard : public std::lock_guard<StdMutex>
65+
// StdLockGuard provides an annotated version of std::lock_guard for us,
66+
// and should only be used when sync.h Mutex/LOCK/etc are not usable.
67+
class SCOPED_LOCKABLE StdLockGuard : public std::lock_guard<StdMutex>
6868
{
6969
public:
70-
explicit LockGuard(StdMutex& cs) EXCLUSIVE_LOCK_FUNCTION(cs) : std::lock_guard<StdMutex>(cs) {}
71-
~LockGuard() UNLOCK_FUNCTION() {};
70+
explicit StdLockGuard(StdMutex& cs) EXCLUSIVE_LOCK_FUNCTION(cs) : std::lock_guard<StdMutex>(cs) {}
71+
~StdLockGuard() UNLOCK_FUNCTION() {}
7272
};
7373

7474
#endif // BITCOIN_THREADSAFETY_H

0 commit comments

Comments
 (0)