diff options
Diffstat (limited to 'Kernel/KernelKit/Semaphore.hpp')
| -rw-r--r-- | Kernel/KernelKit/Semaphore.hpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/Kernel/KernelKit/Semaphore.hpp b/Kernel/KernelKit/Semaphore.hpp new file mode 100644 index 00000000..f12e1282 --- /dev/null +++ b/Kernel/KernelKit/Semaphore.hpp @@ -0,0 +1,42 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#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 |
