summaryrefslogtreecommitdiffhomepage
path: root/NewKernel/KernelKit/Semaphore.hpp
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-05-08 12:32:41 +0200
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-05-08 12:32:41 +0200
commit09dd11ddf800898c00ecb04a65fb5cd10fb481fa (patch)
treeeda0b4e23d6a71da7de3a78f0bb76ec3201dd2f9 /NewKernel/KernelKit/Semaphore.hpp
parentca83108fd138cc0398f900e6a6c0a53ad51aee31 (diff)
MHR-23: :boom: changes, reworked project tree.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'NewKernel/KernelKit/Semaphore.hpp')
-rw-r--r--NewKernel/KernelKit/Semaphore.hpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/NewKernel/KernelKit/Semaphore.hpp b/NewKernel/KernelKit/Semaphore.hpp
new file mode 100644
index 00000000..523fecb5
--- /dev/null
+++ b/NewKernel/KernelKit/Semaphore.hpp
@@ -0,0 +1,42 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#pragma once
+
+#include <NewKit/Defines.hpp>
+#include <CompilerKit/CompilerKit.hxx>
+
+namespace NewOS
+{
+ class ProcessHeader;
+
+ typedef ProcessHeader* ProcessHeaderRef;
+
+ /// @brief Access control class, which locks a task until one is done.
+ class Semaphore final
+ {
+ public:
+ explicit Semaphore() = default;
+ ~Semaphore() = default;
+
+ public:
+ bool IsLocked() const;
+ bool Unlock() noexcept;
+
+ public:
+ void Sync() noexcept;
+
+ public:
+ bool Lock(ProcessHeader* process);
+ bool LockOrWait(ProcessHeader* process, const Int64& seconds);
+
+ public:
+ NEWOS_COPY_DEFAULT(Semaphore);
+
+ private:
+ ProcessHeaderRef fLockingProcess{nullptr};
+ };
+} // namespace NewOS