19 #if defined(__FRC_ROBORIO__) && !defined(WPI_USE_PRIORITY_MUTEX)
20 #define WPI_USE_PRIORITY_MUTEX
23 #if defined(WPI_USE_PRIORITY_MUTEX) && defined(__linux__)
25 #define WPI_HAVE_PRIORITY_MUTEX 1
27 class priority_recursive_mutex {
29 typedef pthread_mutex_t* native_handle_type;
31 constexpr priority_recursive_mutex() noexcept = default;
32 priority_recursive_mutex(const priority_recursive_mutex&) = delete;
33 priority_recursive_mutex& operator=(const priority_recursive_mutex&) = delete;
36 void lock() { pthread_mutex_lock(&m_mutex); }
39 void unlock() { pthread_mutex_unlock(&m_mutex); }
42 bool try_lock() noexcept {
return !pthread_mutex_trylock(&m_mutex); }
44 pthread_mutex_t* native_handle() {
return &m_mutex; }
49 #ifdef __PTHREAD_MUTEX_HAVE_PREV
50 pthread_mutex_t m_mutex = {
51 {0, 0, 0, 0, 0x20 | PTHREAD_MUTEX_RECURSIVE_NP, __PTHREAD_SPINS, {0, 0}}};
53 pthread_mutex_t m_mutex = {
54 {0, 0, 0, 0x20 | PTHREAD_MUTEX_RECURSIVE_NP, 0, {__PTHREAD_SPINS}}};
58 class priority_mutex {
60 typedef pthread_mutex_t* native_handle_type;
62 constexpr priority_mutex() noexcept = default;
63 priority_mutex(const priority_mutex&) = delete;
64 priority_mutex& operator=(const priority_mutex&) = delete;
67 void lock() { pthread_mutex_lock(&m_mutex); }
70 void unlock() { pthread_mutex_unlock(&m_mutex); }
73 bool try_lock() noexcept {
return !pthread_mutex_trylock(&m_mutex); }
75 pthread_mutex_t* native_handle() {
return &m_mutex; }
79 #ifdef __PTHREAD_MUTEX_HAVE_PREV
80 pthread_mutex_t m_mutex = {{0, 0, 0, 0, 0x20, __PTHREAD_SPINS, {0, 0}}};
82 pthread_mutex_t m_mutex = {{0, 0, 0, 0x20, 0, {__PTHREAD_SPINS}}};
86 #endif // defined(WPI_USE_PRIORITY_MUTEX) && defined(__linux__)
WPILib C++ utilities (wpiutil) namespace.
Definition: SmallString.h:21