Why: Locking#

class Mutex#

Public Functions

Mutex()#
~Mutex()#
Mutex(const Mutex&) = delete#
Mutex &operator=(const Mutex&&) = delete#
Mutex(Mutex&&)#
Mutex &operator=(Mutex&&)#
void lock()#

Lock the mutex, blocking the caller until it is available. Not safe to call from an ISR!

Usage in an :cpp:class:Why::IRQ

void unlock()#

Unlock the mutex, unlocking one (if any) waiter

Note that, although unlocking does not block the caller (the unlocker), its use from an ISR is undefined because a mutex has an owner - the thread that successfully locked it. Depending on the underlying OS configuration, the OS might check or not.

class Spinlock#

Public Functions

Spinlock()#
~Spinlock()#
Spinlock(const Spinlock&) = delete#
Spinlock &operator=(const Spinlock&&) = delete#
Spinlock(Spinlock&&)#
Spinlock &operator=(Spinlock&&)#
void lock()#

Spin until an atomic flag can be had

Note that this does not interfere with scheduling, so lock() is safe to call from an ISR.

void unlock()#

Unlock, resetting the flag and resuming a locker/spinner with the flag held.