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:
Thad House
2017-05-11 21:25:22 -07:00
committed by Peter Johnson
parent 16e71eac43
commit efec0c5cc3
47 changed files with 250 additions and 223 deletions

View File

@@ -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);