Remove template types from lock RAII wrapper usages (#1756)

C++17 has template type autodeduction. These wrappers include
std::lock_guard and std::unique_lock.
This commit is contained in:
Tyler Veness
2019-07-07 19:17:14 -07:00
committed by Peter Johnson
parent e582518bae
commit 841ef5d739
90 changed files with 621 additions and 621 deletions

View File

@@ -29,7 +29,7 @@ detail::SafeThreadOwnerBase::~SafeThreadOwnerBase() {
}
void detail::SafeThreadOwnerBase::Start(std::shared_ptr<SafeThread> thr) {
std::lock_guard<wpi::mutex> lock(m_mutex);
std::lock_guard lock(m_mutex);
if (auto thr = m_thread.lock()) return;
m_stdThread = std::thread([=] { thr->Main(); });
thr->m_threadId = m_stdThread.get_id();
@@ -37,7 +37,7 @@ void detail::SafeThreadOwnerBase::Start(std::shared_ptr<SafeThread> thr) {
}
void detail::SafeThreadOwnerBase::Stop() {
std::lock_guard<wpi::mutex> lock(m_mutex);
std::lock_guard lock(m_mutex);
if (auto thr = m_thread.lock()) {
thr->m_active = false;
thr->m_cond.notify_all();
@@ -47,7 +47,7 @@ void detail::SafeThreadOwnerBase::Stop() {
}
void detail::SafeThreadOwnerBase::Join() {
std::unique_lock<wpi::mutex> lock(m_mutex);
std::unique_lock lock(m_mutex);
if (auto thr = m_thread.lock()) {
auto stdThread = std::move(m_stdThread);
m_thread.reset();
@@ -64,25 +64,25 @@ void detail::swap(SafeThreadOwnerBase& lhs, SafeThreadOwnerBase& rhs) noexcept {
using std::swap;
if (&lhs == &rhs) return;
std::lock(lhs.m_mutex, rhs.m_mutex);
std::lock_guard<wpi::mutex> lock_lhs(lhs.m_mutex, std::adopt_lock);
std::lock_guard<wpi::mutex> lock_rhs(rhs.m_mutex, std::adopt_lock);
std::lock_guard lock_lhs(lhs.m_mutex, std::adopt_lock);
std::lock_guard lock_rhs(rhs.m_mutex, std::adopt_lock);
std::swap(lhs.m_stdThread, rhs.m_stdThread);
std::swap(lhs.m_thread, rhs.m_thread);
}
detail::SafeThreadOwnerBase::operator bool() const {
std::lock_guard<wpi::mutex> lock(m_mutex);
std::lock_guard lock(m_mutex);
return !m_thread.expired();
}
std::thread::native_handle_type
detail::SafeThreadOwnerBase::GetNativeThreadHandle() {
std::lock_guard<wpi::mutex> lock(m_mutex);
std::lock_guard lock(m_mutex);
return m_stdThread.native_handle();
}
std::shared_ptr<SafeThread> detail::SafeThreadOwnerBase::GetThreadSharedPtr()
const {
std::lock_guard<wpi::mutex> lock(m_mutex);
std::lock_guard lock(m_mutex);
return m_thread.lock();
}