mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Use wpi::mutex instead of std::mutex. (#730)
This uses a priority-aware mutex on Linux platforms. Fixes #729.
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
|
||||
using namespace frc;
|
||||
|
||||
std::mutex ErrorBase::_globalErrorMutex;
|
||||
wpi::mutex ErrorBase::_globalErrorMutex;
|
||||
Error ErrorBase::_globalError;
|
||||
|
||||
ErrorBase::ErrorBase() { HAL_Initialize(500, 0); }
|
||||
@@ -68,7 +68,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<std::mutex> mutex(_globalErrorMutex);
|
||||
std::lock_guard<wpi::mutex> mutex(_globalErrorMutex);
|
||||
if (_globalError.GetCode() == 0) {
|
||||
_globalError.Clone(m_error);
|
||||
}
|
||||
@@ -97,7 +97,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<std::mutex> mutex(_globalErrorMutex);
|
||||
std::lock_guard<wpi::mutex> mutex(_globalErrorMutex);
|
||||
if (_globalError.GetCode() == 0) {
|
||||
_globalError.Clone(m_error);
|
||||
}
|
||||
@@ -122,7 +122,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<std::mutex> mutex(_globalErrorMutex);
|
||||
std::lock_guard<wpi::mutex> mutex(_globalErrorMutex);
|
||||
if (_globalError.GetCode() == 0) {
|
||||
_globalError.Clone(m_error);
|
||||
}
|
||||
@@ -160,7 +160,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<std::mutex> mutex(_globalErrorMutex);
|
||||
std::lock_guard<wpi::mutex> mutex(_globalErrorMutex);
|
||||
if (_globalError.GetCode() == 0) {
|
||||
_globalError.Clone(m_error);
|
||||
}
|
||||
@@ -186,7 +186,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<std::mutex> mutex(_globalErrorMutex);
|
||||
std::lock_guard<wpi::mutex> mutex(_globalErrorMutex);
|
||||
if (_globalError.GetCode() == 0) {
|
||||
_globalError.Clone(m_error);
|
||||
}
|
||||
@@ -208,7 +208,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<std::mutex> mutex(_globalErrorMutex);
|
||||
std::lock_guard<wpi::mutex> mutex(_globalErrorMutex);
|
||||
|
||||
// Set the current error information for this object.
|
||||
_globalError.Set(code, contextMessage, filename, function, lineNumber,
|
||||
@@ -222,7 +222,7 @@ void ErrorBase::SetGlobalWPIError(llvm::StringRef errorMessage,
|
||||
llvm::StringRef function, int lineNumber) {
|
||||
std::string err = errorMessage.str() + ": " + contextMessage.str();
|
||||
|
||||
std::lock_guard<std::mutex> mutex(_globalErrorMutex);
|
||||
std::lock_guard<wpi::mutex> mutex(_globalErrorMutex);
|
||||
if (_globalError.GetCode() != 0) {
|
||||
_globalError.Clear();
|
||||
}
|
||||
@@ -233,6 +233,6 @@ void ErrorBase::SetGlobalWPIError(llvm::StringRef errorMessage,
|
||||
* Retrieve the current global error.
|
||||
*/
|
||||
Error& ErrorBase::GetGlobalError() {
|
||||
std::lock_guard<std::mutex> mutex(_globalErrorMutex);
|
||||
std::lock_guard<wpi::mutex> mutex(_globalErrorMutex);
|
||||
return _globalError;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user