diff options
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 |
