Cleaned up variable names for std::lock_guard and their associated mutexes (#759)

This commit is contained in:
Tyler Veness
2017-11-22 17:10:21 -08:00
committed by Peter Johnson
parent 96de0b5b11
commit ba879f4663
22 changed files with 136 additions and 137 deletions

View File

@@ -38,12 +38,12 @@ MotorSafetyHelper::MotorSafetyHelper(MotorSafety* safeObject)
m_expiration = DEFAULT_SAFETY_EXPIRATION;
m_stopTime = Timer::GetFPGATimestamp();
std::lock_guard<wpi::mutex> sync(m_listMutex);
std::lock_guard<wpi::mutex> lock(m_listMutex);
m_helperList.insert(this);
}
MotorSafetyHelper::~MotorSafetyHelper() {
std::lock_guard<wpi::mutex> sync(m_listMutex);
std::lock_guard<wpi::mutex> lock(m_listMutex);
m_helperList.erase(this);
}
@@ -53,7 +53,7 @@ MotorSafetyHelper::~MotorSafetyHelper() {
* Resets the timer on this object that is used to do the timeouts.
*/
void MotorSafetyHelper::Feed() {
std::lock_guard<wpi::mutex> sync(m_syncMutex);
std::lock_guard<wpi::mutex> lock(m_thisMutex);
m_stopTime = Timer::GetFPGATimestamp() + m_expiration;
}
@@ -63,7 +63,7 @@ void MotorSafetyHelper::Feed() {
* @param expirationTime The timeout value in seconds.
*/
void MotorSafetyHelper::SetExpiration(double expirationTime) {
std::lock_guard<wpi::mutex> sync(m_syncMutex);
std::lock_guard<wpi::mutex> lock(m_thisMutex);
m_expiration = expirationTime;
}
@@ -73,7 +73,7 @@ void MotorSafetyHelper::SetExpiration(double expirationTime) {
* @return the timeout value in seconds.
*/
double MotorSafetyHelper::GetExpiration() const {
std::lock_guard<wpi::mutex> sync(m_syncMutex);
std::lock_guard<wpi::mutex> lock(m_thisMutex);
return m_expiration;
}
@@ -84,7 +84,7 @@ double MotorSafetyHelper::GetExpiration() const {
* timed out.
*/
bool MotorSafetyHelper::IsAlive() const {
std::lock_guard<wpi::mutex> sync(m_syncMutex);
std::lock_guard<wpi::mutex> lock(m_thisMutex);
return !m_enabled || m_stopTime > Timer::GetFPGATimestamp();
}
@@ -99,7 +99,7 @@ void MotorSafetyHelper::Check() {
DriverStation& ds = DriverStation::GetInstance();
if (!m_enabled || ds.IsDisabled() || ds.IsTest()) return;
std::lock_guard<wpi::mutex> sync(m_syncMutex);
std::lock_guard<wpi::mutex> lock(m_thisMutex);
if (m_stopTime < Timer::GetFPGATimestamp()) {
llvm::SmallString<128> buf;
llvm::raw_svector_ostream desc(buf);
@@ -118,7 +118,7 @@ void MotorSafetyHelper::Check() {
* @param enabled True if motor safety is enforced for this object
*/
void MotorSafetyHelper::SetSafetyEnabled(bool enabled) {
std::lock_guard<wpi::mutex> sync(m_syncMutex);
std::lock_guard<wpi::mutex> lock(m_thisMutex);
m_enabled = enabled;
}
@@ -130,7 +130,7 @@ void MotorSafetyHelper::SetSafetyEnabled(bool enabled) {
* @return True if motor safety is enforced for this device
*/
bool MotorSafetyHelper::IsSafetyEnabled() const {
std::lock_guard<wpi::mutex> sync(m_syncMutex);
std::lock_guard<wpi::mutex> lock(m_thisMutex);
return m_enabled;
}
@@ -141,7 +141,7 @@ bool MotorSafetyHelper::IsSafetyEnabled() const {
* that have timed out.
*/
void MotorSafetyHelper::CheckMotors() {
std::lock_guard<wpi::mutex> sync(m_listMutex);
std::lock_guard<wpi::mutex> lock(m_listMutex);
for (auto elem : m_helperList) {
elem->Check();
}