diff options
Diffstat (limited to 'dev/kernel/KernelKit/BinaryMutex.h')
| -rw-r--r-- | dev/kernel/KernelKit/BinaryMutex.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/dev/kernel/KernelKit/BinaryMutex.h b/dev/kernel/KernelKit/BinaryMutex.h new file mode 100644 index 00000000..21b2ca6d --- /dev/null +++ b/dev/kernel/KernelKit/BinaryMutex.h @@ -0,0 +1,43 @@ +/* ------------------------------------------- + + Copyright (C) 2024-2025, Amlal EL Mahrouss, all rights reserved. + +------------------------------------------- */ + +#pragma once + +#include <NewKit/Defines.h> +#include <KernelKit/Timer.h> +#include <CompilerKit/CompilerKit.h> + +namespace NeOS +{ + class UserProcess; + + typedef UserProcess& UserProcessRef; + + /// @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 Int16& sec) noexcept; + + public: + bool Lock(UserProcess& process); + bool LockOrWait(UserProcess& process, TimerInterface* timer); + + public: + NE_COPY_DEFAULT(BinaryMutex); + + private: + UserProcessRef fLockingProcess; + }; +} // namespace NeOS |
