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:
Tyler Veness
2017-09-28 23:32:35 -07:00
committed by Peter Johnson
parent 19addb04cf
commit dd66b23845
44 changed files with 390 additions and 746 deletions

View File

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