Let lock_guard deduce its template argument
No functional change, this is a cleanup.
With C++17, it's no longer necessary to specify the teplate argument
when it can be deduced from the types of constructor arguments. This
allows de-cluttering our locking statements.
To avoid typos, this patch was mechanically generated:
perl -p -i -e 's/std::lock_guard<std::mutex>/std::lock_guard/g' \
$(find . -name '*.cpp' -o -name '*.h')
Change-Id: Ibb15d9a6c5b1c861d81353e47d25474eb1d4c2df
diff --git a/server/TcpSocketMonitor.cpp b/server/TcpSocketMonitor.cpp
index 864c3be..3e620b1 100644
--- a/server/TcpSocketMonitor.cpp
+++ b/server/TcpSocketMonitor.cpp
@@ -97,7 +97,7 @@
const milliseconds TcpSocketMonitor::kDefaultPollingInterval = milliseconds(30000);
void TcpSocketMonitor::dump(DumpWriter& dw) {
- std::lock_guard<std::mutex> guard(mLock);
+ std::lock_guard guard(mLock);
dw.println("TcpSocketMonitor");
ScopedIndent tcpSocketMonitorDetails(dw);
@@ -150,7 +150,7 @@
}
void TcpSocketMonitor::setPollingInterval(milliseconds nextSleepDurationMs) {
- std::lock_guard<std::mutex> guard(mLock);
+ std::lock_guard guard(mLock);
mNextSleepDurationMs = nextSleepDurationMs;
@@ -160,7 +160,7 @@
void TcpSocketMonitor::resumePolling() {
bool wasSuspended;
{
- std::lock_guard<std::mutex> guard(mLock);
+ std::lock_guard guard(mLock);
wasSuspended = mIsSuspended;
mIsSuspended = false;
@@ -173,7 +173,7 @@
}
void TcpSocketMonitor::suspendPolling() {
- std::lock_guard<std::mutex> guard(mLock);
+ std::lock_guard guard(mLock);
bool wasSuspended = mIsSuspended;
mIsSuspended = true;
@@ -185,7 +185,7 @@
}
void TcpSocketMonitor::poll() {
- std::lock_guard<std::mutex> guard(mLock);
+ std::lock_guard guard(mLock);
if (mIsSuspended) {
return;
@@ -252,7 +252,7 @@
bool isSuspended;
milliseconds nextSleepDurationMs;
{
- std::lock_guard<std::mutex> guard(mLock);
+ std::lock_guard guard(mLock);
isSuspended = mIsSuspended;
nextSleepDurationMs= mNextSleepDurationMs;
}
@@ -266,7 +266,7 @@
}
bool TcpSocketMonitor::isRunning() {
- std::lock_guard<std::mutex> guard(mLock);
+ std::lock_guard guard(mLock);
return mIsRunning;
}
@@ -313,7 +313,7 @@
}
TcpSocketMonitor::TcpSocketMonitor() {
- std::lock_guard<std::mutex> guard(mLock);
+ std::lock_guard guard(mLock);
mNextSleepDurationMs = kDefaultPollingInterval;
mIsRunning = true;
@@ -329,7 +329,7 @@
TcpSocketMonitor::~TcpSocketMonitor() {
{
- std::lock_guard<std::mutex> guard(mLock);
+ std::lock_guard guard(mLock);
mIsRunning = false;
mIsSuspended = true;
}