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

#include <hikogui/concurrency/unfair_recursive_mutex.hpp>

Public Member Functions

 unfair_recursive_mutex (unfair_recursive_mutex const &)=delete
 
unfair_recursive_mutexoperator= (unfair_recursive_mutex const &)=delete
 
int recurse_lock_count () const noexcept
 This function should be used in hi_axiom() to check if the lock is held by current thread.
 
bool try_lock () noexcept
 When try_lock() is called on a thread that already holds the lock true is returned.
 
void lock () noexcept
 
void unlock () noexcept
 

Detailed Description

An unfair recursive-mutex This is a fast implementation of a recursive-mutex which does not fairly arbitrate between multiple blocking threads.

Due to the unfairness it is possible that blocking threads will be completely starved.

This recursive-mutex however does block on a operating system's futex/unfair_mutex primitives and therefor thread priority are properly handled.

On windows and Linux the compiler generally emits the following sequence of instructions:

Member Function Documentation

◆ lock()

void hi::v1::unfair_recursive_mutex::lock ( )
inlinenoexcept
           lea  rbx,[rcx+98h]
           mov  esi,dword ptr gs:[48h]
           mov  eax,dword ptr [rbx+4]
           cmp  eax,esi
           jne  non_recursive
           lea  r15,[rbx+8]
           inc  dword ptr [r15]
           jmp  locked

non_recursive: call unfair_mutex.lock() lea r15,[r14+0A0h] mov dword ptr [r15],r13d mov dword ptr [rbx+4],esi locked:

◆ recurse_lock_count()

int hi::v1::unfair_recursive_mutex::recurse_lock_count ( ) const
inlinenoexcept

This function should be used in hi_axiom() to check if the lock is held by current thread.

Returns
The number of recursive locks the current thread has taken.
Return values
0The current thread does not have a lock, or no-thread have a lock.

◆ try_lock()

bool hi::v1::unfair_recursive_mutex::try_lock ( )
inlinenoexcept

When try_lock() is called on a thread that already holds the lock true is returned.


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