HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Member Functions
v1::wfree_idle_count Class Reference

#include <hikogui/concurrency/wfree_idle_count.hpp>

Public Member Functions

 wfree_idle_count (wfree_idle_count const &)=delete
 
 wfree_idle_count (wfree_idle_count &&)=delete
 
wfree_idle_countoperator= (wfree_idle_count const &)=delete
 
wfree_idle_countoperator= (wfree_idle_count &&)=delete
 
hi_force_inline bool is_locked () const noexcept
 Check if the critical section is locked.
 
hi_force_inline void lock () noexcept
 Start the critical section.
 
hi_force_inline void unlock () noexcept
 End the critical section.
 
hi_force_inline uint64_t operator* () const noexcept
 Get the current idle-count.
 

Detailed Description

Counts how many times a critical section was idle.

A reader thread.

auto lock = std::scoped_lock(idle_count);
... read protected data ...
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:367
hi_force_inline void lock() noexcept
Start the critical section.
Definition wfree_idle_count.hpp:59

A write thread.

idle_count.lock();
... write protected data ...
auto old_version = idle_count.version();
idle_count.unlock();
... wait some time ...
auto new_version = idle_count.expanded_version(version);
// All threads now see the new data.
... Delete old data ...
}

Member Function Documentation

◆ is_locked()

hi_force_inline bool v1::wfree_idle_count::is_locked ( ) const
inlinenoexcept

Check if the critical section is locked.

Note
This is only reliably true when inside a critical section.

◆ lock()

hi_force_inline void v1::wfree_idle_count::lock ( )
inlinenoexcept

Start the critical section.

Note
lock is allowed to be called reentered.

◆ operator*()

hi_force_inline uint64_t v1::wfree_idle_count::operator* ( ) const
inlinenoexcept

Get the current idle-count.

Returns
The number of times the critcal section became idle, modulo 2^23.

◆ unlock()

hi_force_inline void v1::wfree_idle_count::unlock ( )
inlinenoexcept

End the critical section.

Note
It is undefined behavior to call unlock() when not holding the lock.

The documentation for this class was generated from the following file: