summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/mutex.h
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner2015-01-22 23:12:19 -0200
committerGravatar Yuri Kunde Schlesner2015-01-30 11:47:06 -0200
commit882b6fed75b7bf34809493482496e98c498a14e0 (patch)
tree7d44259e18b47559774f1d7e159fbd0c235d0318 /src/core/hle/kernel/mutex.h
parentKernel: Convert AddressArbiter to not use Handles (diff)
downloadyuzu-882b6fed75b7bf34809493482496e98c498a14e0.tar.gz
yuzu-882b6fed75b7bf34809493482496e98c498a14e0.tar.xz
yuzu-882b6fed75b7bf34809493482496e98c498a14e0.zip
Kernel: Convert Mutex to not use Handles
Diffstat (limited to 'src/core/hle/kernel/mutex.h')
-rw-r--r--src/core/hle/kernel/mutex.h52
1 files changed, 39 insertions, 13 deletions
diff --git a/src/core/hle/kernel/mutex.h b/src/core/hle/kernel/mutex.h
index bb8778c98..a6d822e60 100644
--- a/src/core/hle/kernel/mutex.h
+++ b/src/core/hle/kernel/mutex.h
@@ -4,25 +4,51 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <string>
8
7#include "common/common_types.h" 9#include "common/common_types.h"
8 10
9#include "core/hle/kernel/kernel.h" 11#include "core/hle/kernel/kernel.h"
10 12
11namespace Kernel { 13namespace Kernel {
12 14
13/** 15class Thread;
14 * Releases a mutex 16
15 * @param handle Handle to mutex to release 17class Mutex : public WaitObject {
16 */ 18public:
17ResultCode ReleaseMutex(Handle handle); 19 /**
18 20 * Creates a mutex.
19/** 21 * @param initial_locked Specifies if the mutex should be locked initially
20 * Creates a mutex 22 * @param name Optional name of mutex
21 * @param initial_locked Specifies if the mutex should be locked initially 23 * @return Pointer to new Mutex object
22 * @param name Optional name of mutex 24 */
23 * @return Handle to newly created object 25 static ResultVal<SharedPtr<Mutex>> Create(bool initial_locked, std::string name = "Unknown");
24 */ 26
25Handle CreateMutex(bool initial_locked, const std::string& name="Unknown"); 27 std::string GetTypeName() const override { return "Mutex"; }
28 std::string GetName() const override { return name; }
29
30 static const HandleType HANDLE_TYPE = HandleType::Mutex;
31 HandleType GetHandleType() const override { return HANDLE_TYPE; }
32
33 bool initial_locked; ///< Initial lock state when mutex was created
34 bool locked; ///< Current locked state
35 std::string name; ///< Name of mutex (optional)
36 SharedPtr<Thread> holding_thread; ///< Thread that has acquired the mutex
37
38 bool ShouldWait() override;
39 void Acquire() override;
40
41 /**
42 * Acquires the specified mutex for the specified thread
43 * @param mutex Mutex that is to be acquired
44 * @param thread Thread that will acquire the mutex
45 */
46 void Acquire(Thread* thread);
47 void Release();
48
49private:
50 Mutex() = default;
51};
26 52
27/** 53/**
28 * Releases all the mutexes held by the specified thread 54 * Releases all the mutexes held by the specified thread