mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
Remove priority mutex (#644)
* Removed hal::priority_condition_variable * Replaced uses of priority mutexes with std::mutex and std::recursive_mutex This allowed replacing a use of std::condition_variable_any with std::condition_variable. * Replaced all uses of std::recursive_mutex with std::mutex equivalents
This commit is contained in:
committed by
Peter Johnson
parent
19addb04cf
commit
dd66b23845
@@ -8,20 +8,19 @@
|
||||
#include "HAL/handles/HandlesInternal.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <mutex>
|
||||
|
||||
#include <llvm/SmallVector.h>
|
||||
|
||||
#include "HAL/cpp/priority_mutex.h"
|
||||
|
||||
namespace hal {
|
||||
static llvm::SmallVector<HandleBase*, 32> globalHandles;
|
||||
static priority_mutex& GetGlobalHandleMutex() {
|
||||
static priority_mutex globalHandleMutex;
|
||||
static std::mutex& GetGlobalHandleMutex() {
|
||||
static std::mutex globalHandleMutex;
|
||||
return globalHandleMutex;
|
||||
}
|
||||
|
||||
HandleBase::HandleBase() {
|
||||
std::lock_guard<priority_mutex> lock(GetGlobalHandleMutex());
|
||||
std::lock_guard<std::mutex> lock(GetGlobalHandleMutex());
|
||||
auto index = std::find(globalHandles.begin(), globalHandles.end(), this);
|
||||
if (index == globalHandles.end()) {
|
||||
globalHandles.push_back(this);
|
||||
@@ -31,7 +30,7 @@ HandleBase::HandleBase() {
|
||||
}
|
||||
|
||||
HandleBase::~HandleBase() {
|
||||
std::lock_guard<priority_mutex> lock(GetGlobalHandleMutex());
|
||||
std::lock_guard<std::mutex> lock(GetGlobalHandleMutex());
|
||||
auto index = std::find(globalHandles.begin(), globalHandles.end(), this);
|
||||
if (index != globalHandles.end()) {
|
||||
*index = nullptr;
|
||||
@@ -46,7 +45,7 @@ void HandleBase::ResetHandles() {
|
||||
}
|
||||
|
||||
void HandleBase::ResetGlobalHandles() {
|
||||
std::unique_lock<priority_mutex> lock(GetGlobalHandleMutex());
|
||||
std::unique_lock<std::mutex> lock(GetGlobalHandleMutex());
|
||||
for (auto&& i : globalHandles) {
|
||||
if (i != nullptr) {
|
||||
lock.unlock();
|
||||
|
||||
Reference in New Issue
Block a user