summaryrefslogtreecommitdiffhomepage
path: root/src/kernel/KernelKit/BinaryMutex.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/KernelKit/BinaryMutex.h')
-rw-r--r--src/kernel/KernelKit/BinaryMutex.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/kernel/KernelKit/BinaryMutex.h b/src/kernel/KernelKit/BinaryMutex.h
new file mode 100644
index 00000000..5431ab72
--- /dev/null
+++ b/src/kernel/KernelKit/BinaryMutex.h
@@ -0,0 +1,39 @@
+/* ========================================
+
+ Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
+
+======================================== */
+
+#pragma once
+
+#include <CompilerKit/CompilerKit.h>
+#include <KernelKit/Timer.h>
+#include <NeKit/Defines.h>
+
+namespace Kernel {
+class USER_PROCESS;
+
+/// @brief Access control class, which locks a task until one is done.
+class BinaryMutex final {
+ public:
+ explicit BinaryMutex() = default;
+ ~BinaryMutex() = default;
+
+ public:
+ bool IsLocked() const;
+ bool Unlock() noexcept;
+
+ public:
+ BOOL WaitForProcess(const UInt32& sec) noexcept;
+
+ public:
+ bool Lock(USER_PROCESS* process);
+ bool LockAndWait(USER_PROCESS* process, TimerInterface* timer);
+
+ public:
+ NE_COPY_DEFAULT(BinaryMutex)
+
+ private:
+ USER_PROCESS* fLockingProcess{nullptr};
+};
+} // namespace Kernel