13namespace hi::inline v1 {
52 [[nodiscard]] hi_force_inline
bool is_locked() const noexcept
54 return to_bool(_lock_count.load(std::memory_order::relaxed));
61 hi_force_inline
void lock() noexcept
63 auto lock_count = _lock_count.fetch_add(1, std::memory_order::acquire);
71 hi_force_inline
void unlock() noexcept
73 auto lock_count = _lock_count.fetch_sub(1, std::memory_order::release);
74 hi_axiom(lock_count != 0);
75 if (lock_count == 1) {
77 _version.fetch_add(1, std::memory_order::relaxed);
87 return _version.load(std::memory_order::acquire);
This file includes required definitions.
Counts how many times a critical section was idle.
Definition wfree_idle_count.hpp:39
hi_force_inline void lock() noexcept
Start the critical section.
Definition wfree_idle_count.hpp:61
hi_force_inline bool is_locked() const noexcept
Check if the critical section is locked.
Definition wfree_idle_count.hpp:52
hi_force_inline uint64_t operator*() const noexcept
Get the current idle-count.
Definition wfree_idle_count.hpp:85
hi_force_inline void unlock() noexcept
End the critical section.
Definition wfree_idle_count.hpp:71