7#include "unfair_mutex.hpp"
11namespace hi::inline v1 {
68 if (owner.
load(std::memory_order::acquire) == current_thread_id()) {
81 hilet thread_id = current_thread_id();
86 if (owner.
load(std::memory_order::acquire) == thread_id) {
99 owner.
store(thread_id, std::memory_order::release);
128 hilet thread_id = current_thread_id();
133 if (owner.
load(std::memory_order::acquire) == thread_id) {
135 hi_axiom(count != 0);
145 hi_axiom(count == 0);
147 hi_axiom(owner == 0);
148 owner.
store(thread_id, std::memory_order::release);
152 void unlock() noexcept
157 hi_axiom(recurse_lock_count());
165 owner.
store(0, std::memory_order::release);
#define hilet
Invariant should be the default for variables.
Definition required.hpp:23
An unfair mutex This is a fast implementation of a mutex which does not fairly arbitrate between mult...
Definition unfair_mutex.hpp:33
bool try_lock() noexcept
When try_lock() is called from a thread that already owns the lock it will return false.
Definition unfair_mutex.hpp:81
An unfair recursive-mutex This is a fast implementation of a recursive-mutex which does not fairly ar...
Definition unfair_recursive_mutex.hpp:32
int recurse_lock_count() const noexcept
This function should be used in hi_axiom() to check if the lock is held by current thread.
Definition unfair_recursive_mutex.hpp:60
void lock() noexcept
Definition unfair_recursive_mutex.hpp:125
bool try_lock() noexcept
When try_lock() is called on a thread that already holds the lock true is returned.
Definition unfair_recursive_mutex.hpp:78