diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-05-02 17:12:21 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-05-02 17:12:21 +0200 |
| commit | 3ab0a15fb6aba0ad9516da69589b9da8dbd63a8e (patch) | |
| tree | e79c1c0911c3b712a1b02c79d84f0ce5f643bc6c /libs/kstd/src/mutex.cpp | |
| parent | e8904a65e49dea8ce2e1d58eaa3fb60c7cd3443e (diff) | |
| download | kernel-3ab0a15fb6aba0ad9516da69589b9da8dbd63a8e.tar.xz kernel-3ab0a15fb6aba0ad9516da69589b9da8dbd63a8e.zip | |
libs: adopt p1204 layout for kstd
Diffstat (limited to 'libs/kstd/src/mutex.cpp')
| -rw-r--r-- | libs/kstd/src/mutex.cpp | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/libs/kstd/src/mutex.cpp b/libs/kstd/src/mutex.cpp deleted file mode 100644 index 7387657..0000000 --- a/libs/kstd/src/mutex.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include <kstd/mutex> - -#include <kstd/os/error.hpp> - -#include <atomic> - -namespace kstd -{ - - mutex::mutex() = default; - - mutex::~mutex() - { - if (m_locked.test(std::memory_order_relaxed)) - { - os::panic("[KSTD] Tried to destroy a locked mutex."); - } - } - - auto mutex::lock() -> void - { - while (!try_lock()) - { - asm volatile("nop"); - } - } - - auto mutex::try_lock() -> bool - { - return !m_locked.test_and_set(std::memory_order_acquire); - } - - auto mutex::unlock() -> void - { - m_locked.clear(std::memory_order_release); - } - -} // namespace kstd |
