summaryrefslogtreecommitdiffhomepage
path: root/dev/kernel/KernelKit/LockDelegate.h
diff options
context:
space:
mode:
authorAmlal <amlal@nekernel.org>2025-04-25 13:08:33 +0200
committerAmlal <amlal@nekernel.org>2025-04-25 13:08:33 +0200
commitfb790b07aeba8e22e4190cf3e1834d11ecde6c96 (patch)
tree4cec7d1b321307b1d5935577631dae116a658a37 /dev/kernel/KernelKit/LockDelegate.h
parent63a2d92c5dfe976175cda024ec01905d11b43738 (diff)
dev: better .clang-format, ran format command.
Signed-off-by: Amlal <amlal@nekernel.org>
Diffstat (limited to 'dev/kernel/KernelKit/LockDelegate.h')
-rw-r--r--dev/kernel/KernelKit/LockDelegate.h109
1 files changed, 48 insertions, 61 deletions
diff --git a/dev/kernel/KernelKit/LockDelegate.h b/dev/kernel/KernelKit/LockDelegate.h
index ac54d9c5..18ab0cf5 100644
--- a/dev/kernel/KernelKit/LockDelegate.h
+++ b/dev/kernel/KernelKit/LockDelegate.h
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.
+ Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.
------------------------------------------- */
@@ -9,63 +9,50 @@
#include <NewKit/Atom.h>
#include <NewKit/Defines.h>
-namespace Kernel
-{
- enum
- {
- kLockInvalid,
- kLockDone = 200,
- kLockTimedOut,
- kLockCount = 3,
- };
-
- /// @brief Lock condition pointer.
- typedef Boolean* LockPtr;
-
- /// @brief Locking delegate class, hangs until limit.
- /// @tparam N the amount of cycles to wait.
- template <SizeT N>
- class LockDelegate final
- {
- public:
- LockDelegate() = delete;
-
- public:
- explicit LockDelegate(LockPtr expr)
- {
- auto spin = 0U;
-
- while (spin < N)
- {
- if (*expr)
- {
- fLockStatus | kLockDone;
- break;
- }
-
- ++spin;
- }
-
- if (spin > N)
- fLockStatus | kLockTimedOut;
- }
-
- ~LockDelegate() = default;
-
- LockDelegate& operator=(const LockDelegate&) = delete;
- LockDelegate(const LockDelegate&) = delete;
-
- bool Done()
- {
- return fLockStatus[kLockDone] == kLockDone;
- }
-
- bool HasTimedOut()
- {
- return fLockStatus[kLockTimedOut] != kLockTimedOut;
- }
-
- private:
- Atom<UInt> fLockStatus;
- };
-} // namespace Kernel
+namespace Kernel {
+enum {
+ kLockInvalid,
+ kLockDone = 200,
+ kLockTimedOut,
+ kLockCount = 3,
+};
+
+/// @brief Lock condition pointer.
+typedef Boolean* LockPtr;
+
+/// @brief Locking delegate class, hangs until limit.
+/// @tparam N the amount of cycles to wait.
+template <SizeT N>
+class LockDelegate final {
+ public:
+ LockDelegate() = delete;
+
+ public:
+ explicit LockDelegate(LockPtr expr) {
+ auto spin = 0U;
+
+ while (spin < N) {
+ if (*expr) {
+ fLockStatus | kLockDone;
+ break;
+ }
+
+ ++spin;
+ }
+
+ if (spin > N) fLockStatus | kLockTimedOut;
+ }
+
+ ~LockDelegate() = default;
+
+ LockDelegate& operator=(const LockDelegate&) = delete;
+ LockDelegate(const LockDelegate&) = delete;
+
+ bool Done() { return fLockStatus[kLockDone] == kLockDone; }
+
+ bool HasTimedOut() { return fLockStatus[kLockTimedOut] != kLockTimedOut; }
+
+ private:
+ Atom<UInt> fLockStatus;
+};
+} // namespace Kernel