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

@@ -45,7 +45,7 @@ class SerialHelper {
int32_t m_resourceHandle;
static priority_mutex m_nameMutex;
static hal::priority_mutex m_nameMutex;
static std::string m_usbNames[2];
};
} // namespace hal

View File

@@ -22,6 +22,8 @@
#include "priority_mutex.h"
namespace hal {
class priority_condition_variable {
typedef std::chrono::system_clock clock;
@@ -130,3 +132,10 @@ class priority_condition_variable {
Lock& m_lock;
};
};
} // namespace hal
// For backwards compatibility
#ifndef NAMESPACED_PRIORITY
using priority_condition_variable = hal::priority_condition_variable; // NOLINT
#endif

View File

@@ -11,14 +11,18 @@
#include <mutex>
#if defined(FRC_SIMULATOR) || defined(_WIN32)
namespace hal {
// We do not want to use pthreads if in the simulator; however, in the
// simulator, we do not care about priority inversion.
typedef std::mutex priority_mutex;
typedef std::recursive_mutex priority_recursive_mutex;
} // namespace hal
#else // Covers rest of file.
#include <pthread.h>
namespace hal {
class priority_recursive_mutex {
public:
typedef pthread_mutex_t* native_handle_type;
@@ -77,5 +81,12 @@ class priority_mutex {
pthread_mutex_t m_mutex = {{0, 0, 0, 0x20, 0, {0}}};
#endif
};
} // namespace hal
#endif // FRC_SIMULATOR
// For backwards compatibility
#ifndef NAMESPACED_PRIORITY
using priority_mutex = hal::priority_mutex; // NOLINT
using priority_recursive_mutex = hal::priority_recursive_mutex; // NOLINT
#endif