7#include "../utility/utility.hpp"
8#include "../macros.hpp"
53 [[nodiscard]] hi_force_inline
bool is_locked() const noexcept
55 return to_bool(_lock_count.load(std::memory_order::relaxed));
62 hi_force_inline
void lock() noexcept
64 hilet lock_count = _lock_count.fetch_add(1, std::memory_order::acquire);
72 hi_force_inline
void unlock() noexcept
74 auto lock_count = _lock_count.fetch_sub(1, std::memory_order::release);
75 hi_axiom(lock_count != 0);
76 if (lock_count == 1) {
78 _version.fetch_add(1, std::memory_order::relaxed);
88 return _version.load(std::memory_order::acquire);
DOXYGEN BUG.
Definition algorithm.hpp:16
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377
Counts how many times a critical section was idle.
Definition wfree_idle_count.hpp:40
hi_force_inline void lock() noexcept
Start the critical section.
Definition wfree_idle_count.hpp:62
hi_force_inline bool is_locked() const noexcept
Check if the critical section is locked.
Definition wfree_idle_count.hpp:53
hi_force_inline uint64_t operator*() const noexcept
Get the current idle-count.
Definition wfree_idle_count.hpp:86
hi_force_inline void unlock() noexcept
End the critical section.
Definition wfree_idle_count.hpp:72