Skip to content

ASpinlockMutex#

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

Header:#include <AUI/Thread/AMutex.h>
CMake:aui_link(my_target PUBLIC aui::core)

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.

Public Methods#

try_lock#


bool ASpinlockMutex::try_lock()

Tries to acquire the mutex without blocking.

Returns
true if the mutex is successfully acquired, false otherwise.