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

#include <ttauri/unfair_mutex.hpp>

Public Member Functions

 unfair_mutex (unfair_mutex const &)=delete
 
 unfair_mutex (unfair_mutex &&)=delete
 
unfair_mutexoperator= (unfair_mutex const &)=delete
 
unfair_mutexoperator= (unfair_mutex &&)=delete
 
void lock () noexcept
 
bool try_lock () noexcept
 When try_lock() is called from a thread that already owns the lock it will return false.
 
void unlock () noexcept
 

Detailed Description

An unfair mutex This is a fast implementation of a 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 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

◆ try_lock()

bool tt::unfair_mutex::try_lock ( )
inlinenoexcept

When try_lock() is called from a thread that already owns the lock it will return false.

Calling try_lock() in a loop will bypass the operating system's wait system, meaning that no priority inversion will take place.


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