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
@@ -51,7 +51,7 @@ int32_t HAL_SendError(HAL_Bool isError, int32_t errorCode, HAL_Bool isLVCode,
|
||||
// Avoid flooding console by keeping track of previous 5 error
|
||||
// messages and only printing again if they're longer than 1 second old.
|
||||
static constexpr int KEEP_MSGS = 5;
|
||||
std::lock_guard<wpi::mutex> lock(msgMutex);
|
||||
std::lock_guard lock(msgMutex);
|
||||
static std::string prevMsg[KEEP_MSGS];
|
||||
static std::chrono::time_point<std::chrono::steady_clock>
|
||||
prevMsgTime[KEEP_MSGS];
|
||||
@@ -223,7 +223,7 @@ HAL_Bool HAL_IsNewControlData(void) {
|
||||
// worth the cycles to check.
|
||||
int currentCount = 0;
|
||||
{
|
||||
std::unique_lock<wpi::mutex> lock(newDSDataAvailableMutex);
|
||||
std::unique_lock lock(newDSDataAvailableMutex);
|
||||
currentCount = newDSDataAvailableCounter;
|
||||
}
|
||||
if (lastCount == currentCount) return false;
|
||||
@@ -240,7 +240,7 @@ HAL_Bool HAL_WaitForDSDataTimeout(double timeout) {
|
||||
auto timeoutTime =
|
||||
std::chrono::steady_clock::now() + std::chrono::duration<double>(timeout);
|
||||
|
||||
std::unique_lock<wpi::mutex> lock(newDSDataAvailableMutex);
|
||||
std::unique_lock lock(newDSDataAvailableMutex);
|
||||
int currentCount = newDSDataAvailableCounter;
|
||||
while (newDSDataAvailableCounter == currentCount) {
|
||||
if (timeout > 0) {
|
||||
@@ -262,7 +262,7 @@ static int32_t newDataOccur(uint32_t refNum) {
|
||||
// Since we could get other values, require our specific handle
|
||||
// to signal our threads
|
||||
if (refNum != refNumber) return 0;
|
||||
std::lock_guard<wpi::mutex> lock(newDSDataAvailableMutex);
|
||||
std::lock_guard lock(newDSDataAvailableMutex);
|
||||
// Nofify all threads
|
||||
newDSDataAvailableCounter++;
|
||||
newDSDataAvailableCond->notify_all();
|
||||
@@ -276,7 +276,7 @@ void HAL_InitializeDriverStation(void) {
|
||||
// Initial check, as if it's true initialization has finished
|
||||
if (initialized) return;
|
||||
|
||||
std::lock_guard<wpi::mutex> lock(initializeMutex);
|
||||
std::lock_guard lock(initializeMutex);
|
||||
// Second check in case another thread was waiting
|
||||
if (initialized) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user