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
2018-07-02 16:10:57 +02:00
committed by SciresM
parent 18153713d9
commit 5b3e8e1c5d
11 changed files with 52 additions and 91 deletions

View File

@@ -2,6 +2,7 @@
#include <switch.h>
#include <stratosphere.hpp>
#include <memory>
#include <mutex>
#define LAUNCHFLAGS_NOTIFYWHENEXITED(flags) (flags & 1)
#define LAUNCHFLAGS_STARTSUSPENDED(flags) (flags & (kernelAbove500() ? 0x10 : 0x2))
@@ -32,17 +33,10 @@ class Registration {
u64* out_pid;
Result result;
};
class AutoProcessListLock {
private:
bool has_lock;
public:
AutoProcessListLock();
~AutoProcessListLock();
void Unlock();
};
static void InitializeSystemResources();
static IWaitable *GetProcessLaunchStartEvent();
static std::unique_lock<HosRecursiveMutex> GetProcessListUniqueLock();
static void SetProcessListManager(WaitableManager *m);
static Result ProcessLaunchStartCallback(void *arg, Handle *handles, size_t num_handles, u64 timeout);