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

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2016-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. */
@@ -53,7 +53,7 @@ class NotifierHandleContainer
~NotifierHandleContainer() {
ForEach([](HAL_NotifierHandle handle, Notifier* notifier) {
{
std::lock_guard<wpi::mutex> lock(notifier->mutex);
std::lock_guard lock(notifier->mutex);
notifier->triggerTime = UINT64_MAX;
notifier->triggeredTime = 0;
notifier->active = false;
@@ -66,7 +66,7 @@ class NotifierHandleContainer
static NotifierHandleContainer* notifierHandles;
static void alarmCallback(uint32_t, void*) {
std::lock_guard<wpi::mutex> lock(notifierMutex);
std::lock_guard lock(notifierMutex);
int32_t status = 0;
uint64_t currentTime = 0;
@@ -77,7 +77,7 @@ static void alarmCallback(uint32_t, void*) {
notifierHandles->ForEach([&](HAL_NotifierHandle handle, Notifier* notifier) {
if (notifier->triggerTime == UINT64_MAX) return;
if (currentTime == 0) currentTime = HAL_GetFPGATime(&status);
std::unique_lock<wpi::mutex> lock(notifier->mutex);
std::unique_lock lock(notifier->mutex);
if (notifier->triggerTime < currentTime) {
notifier->triggerTime = UINT64_MAX;
notifier->triggeredTime = currentTime;
@@ -119,7 +119,7 @@ HAL_NotifierHandle HAL_InitializeNotifier(int32_t* status) {
std::atexit(cleanupNotifierAtExit);
if (notifierRefCount.fetch_add(1) == 0) {
std::lock_guard<wpi::mutex> lock(notifierMutex);
std::lock_guard lock(notifierMutex);
// create manager and alarm if not already created
if (!notifierManager) {
notifierManager = std::make_unique<tInterruptManager>(
@@ -144,7 +144,7 @@ void HAL_StopNotifier(HAL_NotifierHandle notifierHandle, int32_t* status) {
if (!notifier) return;
{
std::lock_guard<wpi::mutex> lock(notifier->mutex);
std::lock_guard lock(notifier->mutex);
notifier->triggerTime = UINT64_MAX;
notifier->triggeredTime = 0;
notifier->active = false;
@@ -158,7 +158,7 @@ void HAL_CleanNotifier(HAL_NotifierHandle notifierHandle, int32_t* status) {
// Just in case HAL_StopNotifier() wasn't called...
{
std::lock_guard<wpi::mutex> lock(notifier->mutex);
std::lock_guard lock(notifier->mutex);
notifier->triggerTime = UINT64_MAX;
notifier->triggeredTime = 0;
notifier->active = false;
@@ -177,7 +177,7 @@ void HAL_CleanNotifier(HAL_NotifierHandle notifierHandle, int32_t* status) {
// if (notifierAlarm) notifierAlarm->writeEnable(false, status);
// if (notifierManager) notifierManager->disable(status);
// std::lock_guard<wpi::mutex> lock(notifierMutex);
// std::lock_guard lock(notifierMutex);
// notifierAlarm = nullptr;
// notifierManager = nullptr;
// closestTrigger = UINT64_MAX;
@@ -190,12 +190,12 @@ void HAL_UpdateNotifierAlarm(HAL_NotifierHandle notifierHandle,
if (!notifier) return;
{
std::lock_guard<wpi::mutex> lock(notifier->mutex);
std::lock_guard lock(notifier->mutex);
notifier->triggerTime = triggerTime;
notifier->triggeredTime = UINT64_MAX;
}
std::lock_guard<wpi::mutex> lock(notifierMutex);
std::lock_guard lock(notifierMutex);
// Update alarm time if closer than current.
if (triggerTime < closestTrigger) {
bool wasActive = (closestTrigger != UINT64_MAX);
@@ -214,7 +214,7 @@ void HAL_CancelNotifierAlarm(HAL_NotifierHandle notifierHandle,
if (!notifier) return;
{
std::lock_guard<wpi::mutex> lock(notifier->mutex);
std::lock_guard lock(notifier->mutex);
notifier->triggerTime = UINT64_MAX;
}
}
@@ -223,7 +223,7 @@ uint64_t HAL_WaitForNotifierAlarm(HAL_NotifierHandle notifierHandle,
int32_t* status) {
auto notifier = notifierHandles->Get(notifierHandle);
if (!notifier) return 0;
std::unique_lock<wpi::mutex> lock(notifier->mutex);
std::unique_lock lock(notifier->mutex);
notifier->cond.wait(lock, [&] {
return !notifier->active || notifier->triggeredTime != UINT64_MAX;
});