artf4156: Replaced synchronization primitives with C++11 equivalents

Change-Id: I90da739347e875efda2a29dd5484b6dda3cd4753
This commit is contained in:
Tyler Veness
2015-06-25 01:54:20 -07:00
committed by James Kuszmaul
parent 7f5ee01d3e
commit 3f59f3472a
61 changed files with 1293 additions and 768 deletions

View File

@@ -15,7 +15,7 @@
#include <stdio.h>
MotorSafetyHelper *MotorSafetyHelper::m_headHelper = nullptr;
ReentrantSemaphore MotorSafetyHelper::m_listMutex;
priority_recursive_mutex MotorSafetyHelper::m_listMutex;
/**
* The constructor for a MotorSafetyHelper object.
@@ -36,13 +36,13 @@ MotorSafetyHelper::MotorSafetyHelper(MotorSafety *safeObject) {
m_expiration = DEFAULT_SAFETY_EXPIRATION;
m_stopTime = Timer::GetFPGATimestamp();
Synchronized sync(m_listMutex);
std::unique_lock<priority_recursive_mutex> sync(m_listMutex);
m_nextHelper = m_headHelper;
m_headHelper = this;
}
MotorSafetyHelper::~MotorSafetyHelper() {
Synchronized sync(m_listMutex);
std::unique_lock<priority_recursive_mutex> sync(m_listMutex);
if (m_headHelper == this) {
m_headHelper = m_nextHelper;
} else {
@@ -58,7 +58,7 @@ MotorSafetyHelper::~MotorSafetyHelper() {
* Resets the timer on this object that is used to do the timeouts.
*/
void MotorSafetyHelper::Feed() {
Synchronized sync(m_syncMutex);
std::unique_lock<priority_recursive_mutex> sync(m_syncMutex);
m_stopTime = Timer::GetFPGATimestamp() + m_expiration;
}
@@ -67,7 +67,7 @@ void MotorSafetyHelper::Feed() {
* @param expirationTime The timeout value in seconds.
*/
void MotorSafetyHelper::SetExpiration(float expirationTime) {
Synchronized sync(m_syncMutex);
std::unique_lock<priority_recursive_mutex> sync(m_syncMutex);
m_expiration = expirationTime;
}
@@ -76,7 +76,7 @@ void MotorSafetyHelper::SetExpiration(float expirationTime) {
* @return the timeout value in seconds.
*/
float MotorSafetyHelper::GetExpiration() const {
Synchronized sync(m_syncMutex);
std::unique_lock<priority_recursive_mutex> sync(m_syncMutex);
return m_expiration;
}
@@ -86,7 +86,7 @@ float MotorSafetyHelper::GetExpiration() const {
* timed out.
*/
bool MotorSafetyHelper::IsAlive() const {
Synchronized sync(m_syncMutex);
std::unique_lock<priority_recursive_mutex> sync(m_syncMutex);
return !m_enabled || m_stopTime > Timer::GetFPGATimestamp();
}
@@ -102,7 +102,7 @@ void MotorSafetyHelper::Check() {
DriverStation *ds = DriverStation::GetInstance();
if (!m_enabled || ds->IsDisabled() || ds->IsTest()) return;
Synchronized sync(m_syncMutex);
std::unique_lock<priority_recursive_mutex> sync(m_syncMutex);
if (m_stopTime < Timer::GetFPGATimestamp()) {
char buf[128];
char desc[64];
@@ -119,7 +119,7 @@ void MotorSafetyHelper::Check() {
* @param enabled True if motor safety is enforced for this object
*/
void MotorSafetyHelper::SetSafetyEnabled(bool enabled) {
Synchronized sync(m_syncMutex);
std::unique_lock<priority_recursive_mutex> sync(m_syncMutex);
m_enabled = enabled;
}
@@ -129,7 +129,7 @@ void MotorSafetyHelper::SetSafetyEnabled(bool enabled) {
* @return True if motor safety is enforced for this device
*/
bool MotorSafetyHelper::IsSafetyEnabled() const {
Synchronized sync(m_syncMutex);
std::unique_lock<priority_recursive_mutex> sync(m_syncMutex);
return m_enabled;
}
@@ -140,7 +140,7 @@ bool MotorSafetyHelper::IsSafetyEnabled() const {
* timed out.
*/
void MotorSafetyHelper::CheckMotors() {
Synchronized sync(m_listMutex);
std::unique_lock<priority_recursive_mutex> sync(m_listMutex);
for (MotorSafetyHelper *msh = m_headHelper; msh != nullptr;
msh = msh->m_nextHelper) {
msh->Check();