mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Remove priority mutex (#644)
* Removed hal::priority_condition_variable * Replaced uses of priority mutexes with std::mutex and std::recursive_mutex This allowed replacing a use of std::condition_variable_any with std::condition_variable. * Replaced all uses of std::recursive_mutex with std::mutex equivalents
This commit is contained in:
committed by
Peter Johnson
parent
19addb04cf
commit
dd66b23845
@@ -20,7 +20,7 @@
|
||||
|
||||
using namespace frc;
|
||||
|
||||
hal::priority_mutex ErrorBase::_globalErrorMutex;
|
||||
std::mutex ErrorBase::_globalErrorMutex;
|
||||
Error ErrorBase::_globalError;
|
||||
|
||||
/**
|
||||
@@ -64,7 +64,7 @@ void ErrorBase::SetErrnoError(llvm::StringRef contextMessage,
|
||||
m_error.Set(-1, err, filename, function, lineNumber, this);
|
||||
|
||||
// Update the global error if there is not one already set.
|
||||
std::lock_guard<hal::priority_mutex> mutex(_globalErrorMutex);
|
||||
std::lock_guard<std::mutex> mutex(_globalErrorMutex);
|
||||
if (_globalError.GetCode() == 0) {
|
||||
_globalError.Clone(m_error);
|
||||
}
|
||||
@@ -93,7 +93,7 @@ void ErrorBase::SetImaqError(int success, llvm::StringRef contextMessage,
|
||||
m_error.Set(success, err.str(), filename, function, lineNumber, this);
|
||||
|
||||
// Update the global error if there is not one already set.
|
||||
std::lock_guard<hal::priority_mutex> mutex(_globalErrorMutex);
|
||||
std::lock_guard<std::mutex> mutex(_globalErrorMutex);
|
||||
if (_globalError.GetCode() == 0) {
|
||||
_globalError.Clone(m_error);
|
||||
}
|
||||
@@ -118,7 +118,7 @@ void ErrorBase::SetError(Error::Code code, llvm::StringRef contextMessage,
|
||||
m_error.Set(code, contextMessage, filename, function, lineNumber, this);
|
||||
|
||||
// Update the global error if there is not one already set.
|
||||
std::lock_guard<hal::priority_mutex> mutex(_globalErrorMutex);
|
||||
std::lock_guard<std::mutex> mutex(_globalErrorMutex);
|
||||
if (_globalError.GetCode() == 0) {
|
||||
_globalError.Clone(m_error);
|
||||
}
|
||||
@@ -156,7 +156,7 @@ void ErrorBase::SetErrorRange(Error::Code code, int32_t minRange,
|
||||
delete[] buf;
|
||||
|
||||
// Update the global error if there is not one already set.
|
||||
std::lock_guard<hal::priority_mutex> mutex(_globalErrorMutex);
|
||||
std::lock_guard<std::mutex> mutex(_globalErrorMutex);
|
||||
if (_globalError.GetCode() == 0) {
|
||||
_globalError.Clone(m_error);
|
||||
}
|
||||
@@ -182,7 +182,7 @@ void ErrorBase::SetWPIError(llvm::StringRef errorMessage, Error::Code code,
|
||||
m_error.Set(code, err, filename, function, lineNumber, this);
|
||||
|
||||
// Update the global error if there is not one already set.
|
||||
std::lock_guard<hal::priority_mutex> mutex(_globalErrorMutex);
|
||||
std::lock_guard<std::mutex> mutex(_globalErrorMutex);
|
||||
if (_globalError.GetCode() == 0) {
|
||||
_globalError.Clone(m_error);
|
||||
}
|
||||
@@ -204,7 +204,7 @@ void ErrorBase::SetGlobalError(Error::Code code, llvm::StringRef contextMessage,
|
||||
llvm::StringRef function, int lineNumber) {
|
||||
// If there was an error
|
||||
if (code != 0) {
|
||||
std::lock_guard<hal::priority_mutex> mutex(_globalErrorMutex);
|
||||
std::lock_guard<std::mutex> mutex(_globalErrorMutex);
|
||||
|
||||
// Set the current error information for this object.
|
||||
_globalError.Set(code, contextMessage, filename, function, lineNumber,
|
||||
@@ -218,7 +218,7 @@ void ErrorBase::SetGlobalWPIError(llvm::StringRef errorMessage,
|
||||
llvm::StringRef function, int lineNumber) {
|
||||
std::string err = errorMessage.str() + ": " + contextMessage.str();
|
||||
|
||||
std::lock_guard<hal::priority_mutex> mutex(_globalErrorMutex);
|
||||
std::lock_guard<std::mutex> mutex(_globalErrorMutex);
|
||||
if (_globalError.GetCode() != 0) {
|
||||
_globalError.Clear();
|
||||
}
|
||||
@@ -229,6 +229,6 @@ void ErrorBase::SetGlobalWPIError(llvm::StringRef errorMessage,
|
||||
* Retrieve the current global error.
|
||||
*/
|
||||
Error& ErrorBase::GetGlobalError() {
|
||||
std::lock_guard<hal::priority_mutex> mutex(_globalErrorMutex);
|
||||
std::lock_guard<std::mutex> mutex(_globalErrorMutex);
|
||||
return _globalError;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user