summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/k_light_lock.h
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2021-01-16 06:58:44 +0100
committerbunnei <bunneidev@gmail.com>2021-01-29 06:42:26 +0100
commit5a4fc4a5299a3835a57ae8a35c6de51459df70c0 (patch)
treebe8fa37ff42d1928829e5e8769715d6a4d8cb0f5 /src/core/hle/kernel/k_light_lock.h
parentcore: hle: kernel: Implement KThreadQueue. (diff)
downloadyuzu-5a4fc4a5299a3835a57ae8a35c6de51459df70c0.tar
yuzu-5a4fc4a5299a3835a57ae8a35c6de51459df70c0.tar.gz
yuzu-5a4fc4a5299a3835a57ae8a35c6de51459df70c0.tar.bz2
yuzu-5a4fc4a5299a3835a57ae8a35c6de51459df70c0.tar.lz
yuzu-5a4fc4a5299a3835a57ae8a35c6de51459df70c0.tar.xz
yuzu-5a4fc4a5299a3835a57ae8a35c6de51459df70c0.tar.zst
yuzu-5a4fc4a5299a3835a57ae8a35c6de51459df70c0.zip
Diffstat (limited to '')
-rw-r--r--src/core/hle/kernel/k_light_lock.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/core/hle/kernel/k_light_lock.h b/src/core/hle/kernel/k_light_lock.h
new file mode 100644
index 000000000..f4c45f76a
--- /dev/null
+++ b/src/core/hle/kernel/k_light_lock.h
@@ -0,0 +1,41 @@
+// Copyright 2021 yuzu Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include <atomic>
+
+#include "common/common_types.h"
+#include "core/hle/kernel/k_scoped_lock.h"
+
+namespace Kernel {
+
+class KernelCore;
+
+class KLightLock {
+public:
+ explicit KLightLock(KernelCore& kernel_) : kernel{kernel_} {}
+
+ void Lock();
+
+ void Unlock();
+
+ void LockSlowPath(uintptr_t owner, uintptr_t cur_thread);
+
+ void UnlockSlowPath(uintptr_t cur_thread);
+
+ bool IsLocked() const {
+ return tag != 0;
+ }
+
+ bool IsLockedByCurrentThread() const;
+
+private:
+ std::atomic<uintptr_t> tag{};
+ KernelCore& kernel;
+};
+
+using KScopedLightLock = KScopedLock<KLightLock>;
+
+} // namespace Kernel