mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
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:
committed by
Peter Johnson
parent
e582518bae
commit
841ef5d739
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -16,7 +16,7 @@ wpi::mutex Resource::m_createMutex;
|
||||
|
||||
void Resource::CreateResourceObject(std::unique_ptr<Resource>& r,
|
||||
uint32_t elements) {
|
||||
std::lock_guard<wpi::mutex> lock(m_createMutex);
|
||||
std::lock_guard lock(m_createMutex);
|
||||
if (!r) {
|
||||
r = std::make_unique<Resource>(elements);
|
||||
}
|
||||
@@ -27,7 +27,7 @@ Resource::Resource(uint32_t elements) {
|
||||
}
|
||||
|
||||
uint32_t Resource::Allocate(const std::string& resourceDesc) {
|
||||
std::lock_guard<wpi::mutex> lock(m_allocateMutex);
|
||||
std::lock_guard lock(m_allocateMutex);
|
||||
for (uint32_t i = 0; i < m_isAllocated.size(); i++) {
|
||||
if (!m_isAllocated[i]) {
|
||||
m_isAllocated[i] = true;
|
||||
@@ -39,7 +39,7 @@ uint32_t Resource::Allocate(const std::string& resourceDesc) {
|
||||
}
|
||||
|
||||
uint32_t Resource::Allocate(uint32_t index, const std::string& resourceDesc) {
|
||||
std::lock_guard<wpi::mutex> lock(m_allocateMutex);
|
||||
std::lock_guard lock(m_allocateMutex);
|
||||
if (index >= m_isAllocated.size()) {
|
||||
wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, resourceDesc);
|
||||
return std::numeric_limits<uint32_t>::max();
|
||||
@@ -53,7 +53,7 @@ uint32_t Resource::Allocate(uint32_t index, const std::string& resourceDesc) {
|
||||
}
|
||||
|
||||
void Resource::Free(uint32_t index) {
|
||||
std::unique_lock<wpi::mutex> lock(m_allocateMutex);
|
||||
std::unique_lock lock(m_allocateMutex);
|
||||
if (index == std::numeric_limits<uint32_t>::max()) return;
|
||||
if (index >= m_isAllocated.size()) {
|
||||
wpi_setWPIError(NotAllocated);
|
||||
|
||||
Reference in New Issue
Block a user