AUI Framework  develop
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
ASpinlockMutex Class Reference

Synchronization primitive that is implemented with atomic values instead of doing syscalls. More...

#include <AUI/Thread/AMutex.h>

Public Member Functions#

void lock ()
 
bool try_lock () noexcept
 Tries to acquire the mutex without blocking.
 
void unlock () noexcept
 
bool is_locked () const noexcept
 

Detailed Description#

In contrast to a regular mutex, threads will busy-wait (infinitely check for unlocked state) and waste CPU cycles instead of yielding the CPU to another thread with a syscall.

ASpinlockMutex may be faster than a regular mutex in some cases. Use benchmarks to compare.

Member Function Documentation#

◆ try_lock()#

bool ASpinlockMutex::try_lock ( )
inlinenodiscardnoexcept
Returns
true if the mutex is successfully acquired, false otherwise.