summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/mutex.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2014-06-02 20:38:34 -0400
committerGravatar bunnei2014-06-02 20:38:34 -0400
commitb78aff85857a3a356fdf11e1dbc4e5f52490676e (patch)
tree0cb0b9855ae2eed179fb1401e3edbcbd7d59f6f3 /src/core/hle/kernel/mutex.cpp
parentkernel: moved position of * for GetTypeName and GetName (diff)
downloadyuzu-b78aff85857a3a356fdf11e1dbc4e5f52490676e.tar.gz
yuzu-b78aff85857a3a356fdf11e1dbc4e5f52490676e.tar.xz
yuzu-b78aff85857a3a356fdf11e1dbc4e5f52490676e.zip
svc: added optional name field to Event and Mutex (used for debugging)
Diffstat (limited to 'src/core/hle/kernel/mutex.cpp')
-rw-r--r--src/core/hle/kernel/mutex.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp
index 5ac88cd85..7e60fbfe0 100644
--- a/src/core/hle/kernel/mutex.cpp
+++ b/src/core/hle/kernel/mutex.cpp
@@ -16,6 +16,7 @@ namespace Kernel {
16class Mutex : public Object { 16class Mutex : public Object {
17public: 17public:
18 const char* GetTypeName() { return "Mutex"; } 18 const char* GetTypeName() { return "Mutex"; }
19 const char* GetName() { return name.c_str(); }
19 20
20 static Kernel::HandleType GetStaticHandleType() { return Kernel::HandleType::Mutex; } 21 static Kernel::HandleType GetStaticHandleType() { return Kernel::HandleType::Mutex; }
21 Kernel::HandleType GetHandleType() const { return Kernel::HandleType::Mutex; } 22 Kernel::HandleType GetHandleType() const { return Kernel::HandleType::Mutex; }
@@ -24,6 +25,7 @@ public:
24 bool locked; ///< Current locked state 25 bool locked; ///< Current locked state
25 Handle lock_thread; ///< Handle to thread that currently has mutex 26 Handle lock_thread; ///< Handle to thread that currently has mutex
26 std::vector<Handle> waiting_threads; ///< Threads that are waiting for the mutex 27 std::vector<Handle> waiting_threads; ///< Threads that are waiting for the mutex
28 std::string name; ///< Name of mutex (optional)
27 29
28 /** 30 /**
29 * Synchronize kernel object 31 * Synchronize kernel object
@@ -128,13 +130,15 @@ Result ReleaseMutex(Handle handle) {
128 * Creates a mutex 130 * Creates a mutex
129 * @param handle Reference to handle for the newly created mutex 131 * @param handle Reference to handle for the newly created mutex
130 * @param initial_locked Specifies if the mutex should be locked initially 132 * @param initial_locked Specifies if the mutex should be locked initially
133 * @param name Optional name of mutex
131 * @return Pointer to new Mutex object 134 * @return Pointer to new Mutex object
132 */ 135 */
133Mutex* CreateMutex(Handle& handle, bool initial_locked) { 136Mutex* CreateMutex(Handle& handle, bool initial_locked, const std::string name) {
134 Mutex* mutex = new Mutex; 137 Mutex* mutex = new Mutex;
135 handle = Kernel::g_object_pool.Create(mutex); 138 handle = Kernel::g_object_pool.Create(mutex);
136 139
137 mutex->locked = mutex->initial_locked = initial_locked; 140 mutex->locked = mutex->initial_locked = initial_locked;
141 mutex->name = name;
138 142
139 // Acquire mutex with current thread if initialized as locked... 143 // Acquire mutex with current thread if initialized as locked...
140 if (mutex->locked) { 144 if (mutex->locked) {
@@ -150,10 +154,12 @@ Mutex* CreateMutex(Handle& handle, bool initial_locked) {
150/** 154/**
151 * Creates a mutex 155 * Creates a mutex
152 * @param initial_locked Specifies if the mutex should be locked initially 156 * @param initial_locked Specifies if the mutex should be locked initially
157 * @param name Optional name of mutex
158 * @return Handle to newly created object
153 */ 159 */
154Handle CreateMutex(bool initial_locked) { 160Handle CreateMutex(bool initial_locked, std::string name) {
155 Handle handle; 161 Handle handle;
156 Mutex* mutex = CreateMutex(handle, initial_locked); 162 Mutex* mutex = CreateMutex(handle, initial_locked, name);
157 return handle; 163 return handle;
158} 164}
159 165