Use wpi::mutex instead of std::mutex. (#730)

This uses a priority-aware mutex on Linux platforms.

Fixes #729.
This commit is contained in:
Peter Johnson
2017-11-13 09:51:48 -08:00
committed by GitHub
parent 35d68d2a34
commit 4d559f3856
86 changed files with 491 additions and 839 deletions

View File

@@ -15,7 +15,7 @@
using namespace frc;
std::mutex Notifier::m_destructorMutex;
wpi::mutex Notifier::m_destructorMutex;
/**
* Create a Notifier for timer event notification.
@@ -45,8 +45,8 @@ Notifier::~Notifier() {
/* Acquire the mutex; this makes certain that the handler is not being
* executed by the interrupt manager.
*/
std::lock_guard<std::mutex> lockStatic(Notifier::m_destructorMutex);
std::lock_guard<std::mutex> lock(m_processMutex);
std::lock_guard<wpi::mutex> lockStatic(Notifier::m_destructorMutex);
std::lock_guard<wpi::mutex> lock(m_processMutex);
}
/**
@@ -69,7 +69,7 @@ void Notifier::Notify(uint64_t currentTimeInt, HAL_NotifierHandle handle) {
Notifier* notifier;
{
// Lock static mutex to grab the notifier param
std::lock_guard<std::mutex> lock(Notifier::m_destructorMutex);
std::lock_guard<wpi::mutex> lock(Notifier::m_destructorMutex);
int32_t status = 0;
auto notifierPointer = HAL_GetNotifierParam(handle, &status);
if (notifierPointer == nullptr) return;
@@ -96,7 +96,7 @@ void Notifier::Notify(uint64_t currentTimeInt, HAL_NotifierHandle handle) {
* @param delay Seconds to wait before the handler is called.
*/
void Notifier::StartSingle(double delay) {
std::lock_guard<std::mutex> sync(m_processMutex);
std::lock_guard<wpi::mutex> sync(m_processMutex);
m_periodic = false;
m_period = delay;
m_expirationTime = GetClock() + m_period;
@@ -114,7 +114,7 @@ void Notifier::StartSingle(double delay) {
* after the call to this method.
*/
void Notifier::StartPeriodic(double period) {
std::lock_guard<std::mutex> sync(m_processMutex);
std::lock_guard<wpi::mutex> sync(m_processMutex);
m_periodic = true;
m_period = period;
m_expirationTime = GetClock() + m_period;
@@ -137,6 +137,6 @@ void Notifier::Stop() {
// Wait for a currently executing handler to complete before returning from
// Stop()
std::lock_guard<std::mutex> lockStatic(Notifier::m_destructorMutex);
std::lock_guard<std::mutex> lock(m_processMutex);
std::lock_guard<wpi::mutex> lockStatic(Notifier::m_destructorMutex);
std::lock_guard<wpi::mutex> lock(m_processMutex);
}