summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/k_spin_lock.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/core/hle/kernel/k_spin_lock.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/core/hle/kernel/k_spin_lock.h b/src/core/hle/kernel/k_spin_lock.h
new file mode 100644
index 000000000..12c4b2e88
--- /dev/null
+++ b/src/core/hle/kernel/k_spin_lock.h
@@ -0,0 +1,33 @@
+// Copyright 2021 yuzu Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include <atomic>
+
+#include "core/hle/kernel/k_scoped_lock.h"
+
+namespace Kernel {
+
+class KSpinLock {
+public:
+ KSpinLock() = default;
+
+ KSpinLock(const KSpinLock&) = delete;
+ KSpinLock& operator=(const KSpinLock&) = delete;
+
+ KSpinLock(KSpinLock&&) = delete;
+ KSpinLock& operator=(KSpinLock&&) = delete;
+
+ void Lock();
+ void Unlock();
+ [[nodiscard]] bool TryLock();
+
+private:
+ std::atomic_flag lck = ATOMIC_FLAG_INIT;
+};
+
+using KScopedSpinLock = KScopedLock<KSpinLock>;
+
+} // namespace Kernel