mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-30 02:31:44 +00:00
Cleaned up variable names for std::lock_guard and their associated mutexes (#759)
This commit is contained in:
committed by
Peter Johnson
parent
96de0b5b11
commit
ba879f4663
@@ -55,12 +55,12 @@ template <typename THandle, typename TStruct, int16_t size,
|
||||
HAL_HandleEnum enumValue>
|
||||
THandle LimitedHandleResource<THandle, TStruct, size, enumValue>::Allocate() {
|
||||
// globally lock to loop through indices
|
||||
std::lock_guard<wpi::mutex> sync(m_allocateMutex);
|
||||
std::lock_guard<wpi::mutex> lock(m_allocateMutex);
|
||||
for (int16_t i = 0; i < size; i++) {
|
||||
if (m_structures[i] == nullptr) {
|
||||
// if a false index is found, grab its specific mutex
|
||||
// and allocate it.
|
||||
std::lock_guard<wpi::mutex> sync(m_handleMutexes[i]);
|
||||
std::lock_guard<wpi::mutex> lock(m_handleMutexes[i]);
|
||||
m_structures[i] = std::make_shared<TStruct>();
|
||||
return static_cast<THandle>(createHandle(i, enumValue, m_version));
|
||||
}
|
||||
@@ -77,7 +77,7 @@ LimitedHandleResource<THandle, TStruct, size, enumValue>::Get(THandle handle) {
|
||||
if (index < 0 || index >= size) {
|
||||
return nullptr;
|
||||
}
|
||||
std::lock_guard<wpi::mutex> sync(m_handleMutexes[index]);
|
||||
std::lock_guard<wpi::mutex> lock(m_handleMutexes[index]);
|
||||
// return structure. Null will propogate correctly, so no need to manually
|
||||
// check.
|
||||
return m_structures[index];
|
||||
@@ -91,8 +91,8 @@ void LimitedHandleResource<THandle, TStruct, size, enumValue>::Free(
|
||||
int16_t index = getHandleTypedIndex(handle, enumValue, m_version);
|
||||
if (index < 0 || index >= size) return;
|
||||
// lock and deallocated handle
|
||||
std::lock_guard<wpi::mutex> sync(m_allocateMutex);
|
||||
std::lock_guard<wpi::mutex> lock(m_handleMutexes[index]);
|
||||
std::lock_guard<wpi::mutex> allocateLock(m_allocateMutex);
|
||||
std::lock_guard<wpi::mutex> handleLock(m_handleMutexes[index]);
|
||||
m_structures[index].reset();
|
||||
}
|
||||
|
||||
@@ -100,9 +100,9 @@ template <typename THandle, typename TStruct, int16_t size,
|
||||
HAL_HandleEnum enumValue>
|
||||
void LimitedHandleResource<THandle, TStruct, size, enumValue>::ResetHandles() {
|
||||
{
|
||||
std::lock_guard<wpi::mutex> lock(m_allocateMutex);
|
||||
std::lock_guard<wpi::mutex> allocateLock(m_allocateMutex);
|
||||
for (int i = 0; i < size; i++) {
|
||||
std::lock_guard<wpi::mutex> sync(m_handleMutexes[i]);
|
||||
std::lock_guard<wpi::mutex> handleLock(m_handleMutexes[i]);
|
||||
m_structures[i].reset();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user