stratosphere: Use RAII for locks

This renames the Mutex class member functions so that the mutex types
satisfy Lockable.

This makes them usable with standard std::scoped_lock
and std::unique_lock, which lets us use RAII and avoids the need
for a custom RAII wrapper :)
This commit is contained in:
Léo Lam authored and SciresM committed 2018-07-10 09:38:18 -07:00
1 parent 18153713d9
commit 5b3e8e1c5d
11 files changed
+52 -91

No files matched your search

+4 -11
View File
@@ -1,4 +1,5 @@
#pragma once
#include <mutex>
#include <switch.h>
#include <stratosphere.hpp>
#include "pm_registration.hpp"
@@ -36,18 +37,10 @@ class ProcessList final {
public:
std::vector<std::shared_ptr<Registration::Process>> processes;
void Lock() {
this->mutex.Lock();
auto get_unique_lock() {
return std::unique_lock{this->mutex};
}
void Unlock() {
this->mutex.Unlock();
}
bool TryLock() {
return this->mutex.TryLock();
}
void set_manager(WaitableManager *manager) {
this->manager = manager;
}