mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
Moves the HAL priority_ custom types to the hal namespace (#532)
There is a shim for backwards compatibility, just like the frc namespace. As with the frc namespace, the library compiles without the shim.
This commit is contained in:
committed by
Peter Johnson
parent
16e71eac43
commit
efec0c5cc3
@@ -41,7 +41,7 @@ void Scheduler::SetEnabled(bool enabled) { m_enabled = enabled; }
|
||||
* @param command The command to be scheduled
|
||||
*/
|
||||
void Scheduler::AddCommand(Command* command) {
|
||||
std::lock_guard<priority_mutex> sync(m_additionsLock);
|
||||
std::lock_guard<hal::priority_mutex> sync(m_additionsLock);
|
||||
if (std::find(m_additions.begin(), m_additions.end(), command) !=
|
||||
m_additions.end())
|
||||
return;
|
||||
@@ -49,7 +49,7 @@ void Scheduler::AddCommand(Command* command) {
|
||||
}
|
||||
|
||||
void Scheduler::AddButton(ButtonScheduler* button) {
|
||||
std::lock_guard<priority_mutex> sync(m_buttonsLock);
|
||||
std::lock_guard<hal::priority_mutex> sync(m_buttonsLock);
|
||||
m_buttons.push_back(button);
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ void Scheduler::Run() {
|
||||
{
|
||||
if (!m_enabled) return;
|
||||
|
||||
std::lock_guard<priority_mutex> sync(m_buttonsLock);
|
||||
std::lock_guard<hal::priority_mutex> sync(m_buttonsLock);
|
||||
for (auto rButtonIter = m_buttons.rbegin(); rButtonIter != m_buttons.rend();
|
||||
rButtonIter++) {
|
||||
(*rButtonIter)->Execute();
|
||||
@@ -138,7 +138,7 @@ void Scheduler::Run() {
|
||||
|
||||
// Add the new things
|
||||
{
|
||||
std::lock_guard<priority_mutex> sync(m_additionsLock);
|
||||
std::lock_guard<hal::priority_mutex> sync(m_additionsLock);
|
||||
for (auto additionsIter = m_additions.begin();
|
||||
additionsIter != m_additions.end(); additionsIter++) {
|
||||
ProcessCommandAddition(*additionsIter);
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
using namespace frc;
|
||||
|
||||
priority_mutex ErrorBase::_globalErrorMutex;
|
||||
hal::priority_mutex ErrorBase::_globalErrorMutex;
|
||||
Error ErrorBase::_globalError;
|
||||
|
||||
/**
|
||||
@@ -62,7 +62,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<priority_mutex> mutex(_globalErrorMutex);
|
||||
std::lock_guard<hal::priority_mutex> mutex(_globalErrorMutex);
|
||||
if (_globalError.GetCode() == 0) {
|
||||
_globalError.Clone(m_error);
|
||||
}
|
||||
@@ -90,7 +90,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<priority_mutex> mutex(_globalErrorMutex);
|
||||
std::lock_guard<hal::priority_mutex> mutex(_globalErrorMutex);
|
||||
if (_globalError.GetCode() == 0) {
|
||||
_globalError.Clone(m_error);
|
||||
}
|
||||
@@ -115,7 +115,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<priority_mutex> mutex(_globalErrorMutex);
|
||||
std::lock_guard<hal::priority_mutex> mutex(_globalErrorMutex);
|
||||
if (_globalError.GetCode() == 0) {
|
||||
_globalError.Clone(m_error);
|
||||
}
|
||||
@@ -153,7 +153,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<priority_mutex> mutex(_globalErrorMutex);
|
||||
std::lock_guard<hal::priority_mutex> mutex(_globalErrorMutex);
|
||||
if (_globalError.GetCode() == 0) {
|
||||
_globalError.Clone(m_error);
|
||||
}
|
||||
@@ -179,7 +179,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<priority_mutex> mutex(_globalErrorMutex);
|
||||
std::lock_guard<hal::priority_mutex> mutex(_globalErrorMutex);
|
||||
if (_globalError.GetCode() == 0) {
|
||||
_globalError.Clone(m_error);
|
||||
}
|
||||
@@ -201,7 +201,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<priority_mutex> mutex(_globalErrorMutex);
|
||||
std::lock_guard<hal::priority_mutex> mutex(_globalErrorMutex);
|
||||
|
||||
// Set the current error information for this object.
|
||||
_globalError.Set(code, contextMessage, filename, function, lineNumber,
|
||||
@@ -215,7 +215,7 @@ void ErrorBase::SetGlobalWPIError(llvm::StringRef errorMessage,
|
||||
llvm::StringRef function, int lineNumber) {
|
||||
std::string err = errorMessage.str() + ": " + contextMessage.str();
|
||||
|
||||
std::lock_guard<priority_mutex> mutex(_globalErrorMutex);
|
||||
std::lock_guard<hal::priority_mutex> mutex(_globalErrorMutex);
|
||||
if (_globalError.GetCode() != 0) {
|
||||
_globalError.Clear();
|
||||
}
|
||||
@@ -226,6 +226,6 @@ void ErrorBase::SetGlobalWPIError(llvm::StringRef errorMessage,
|
||||
* Retrieve the current global error.
|
||||
*/
|
||||
Error& ErrorBase::GetGlobalError() {
|
||||
std::lock_guard<priority_mutex> mutex(_globalErrorMutex);
|
||||
std::lock_guard<hal::priority_mutex> mutex(_globalErrorMutex);
|
||||
return _globalError;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
using namespace frc;
|
||||
|
||||
priority_recursive_mutex Resource::m_createLock;
|
||||
hal::priority_recursive_mutex Resource::m_createLock;
|
||||
|
||||
/**
|
||||
* Allocate storage for a new instance of Resource.
|
||||
@@ -22,7 +22,7 @@ priority_recursive_mutex Resource::m_createLock;
|
||||
* elements - 1].
|
||||
*/
|
||||
Resource::Resource(uint32_t elements) {
|
||||
std::lock_guard<priority_recursive_mutex> sync(m_createLock);
|
||||
std::lock_guard<hal::priority_recursive_mutex> sync(m_createLock);
|
||||
m_isAllocated = std::vector<bool>(elements, false);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ Resource::Resource(uint32_t elements) {
|
||||
*/
|
||||
/*static*/ void Resource::CreateResourceObject(std::unique_ptr<Resource>& r,
|
||||
uint32_t elements) {
|
||||
std::lock_guard<priority_recursive_mutex> sync(m_createLock);
|
||||
std::lock_guard<hal::priority_recursive_mutex> sync(m_createLock);
|
||||
if (!r) {
|
||||
r = std::make_unique<Resource>(elements);
|
||||
}
|
||||
@@ -53,7 +53,7 @@ Resource::Resource(uint32_t elements) {
|
||||
* allocated.
|
||||
*/
|
||||
uint32_t Resource::Allocate(const std::string& resourceDesc) {
|
||||
std::lock_guard<priority_recursive_mutex> sync(m_allocateLock);
|
||||
std::lock_guard<hal::priority_recursive_mutex> sync(m_allocateLock);
|
||||
for (uint32_t i = 0; i < m_isAllocated.size(); i++) {
|
||||
if (!m_isAllocated[i]) {
|
||||
m_isAllocated[i] = true;
|
||||
@@ -71,7 +71,7 @@ uint32_t Resource::Allocate(const std::string& resourceDesc) {
|
||||
* verified unallocated, then returned.
|
||||
*/
|
||||
uint32_t Resource::Allocate(uint32_t index, const std::string& resourceDesc) {
|
||||
std::lock_guard<priority_recursive_mutex> sync(m_allocateLock);
|
||||
std::lock_guard<hal::priority_recursive_mutex> sync(m_allocateLock);
|
||||
if (index >= m_isAllocated.size()) {
|
||||
wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, resourceDesc);
|
||||
return std::numeric_limits<uint32_t>::max();
|
||||
@@ -92,7 +92,7 @@ uint32_t Resource::Allocate(uint32_t index, const std::string& resourceDesc) {
|
||||
* be reused somewhere else in the program.
|
||||
*/
|
||||
void Resource::Free(uint32_t index) {
|
||||
std::unique_lock<priority_recursive_mutex> sync(m_allocateLock);
|
||||
std::unique_lock<hal::priority_recursive_mutex> sync(m_allocateLock);
|
||||
if (index == std::numeric_limits<uint32_t>::max()) return;
|
||||
if (index >= m_isAllocated.size()) {
|
||||
wpi_setWPIError(NotAllocated);
|
||||
|
||||
Reference in New Issue
Block a user