|
Open Model Railroad Network (OpenMRN)
|
Lightweight locking class for protecting small critical sections. More...
#include <Atomic.hxx>
Public Member Functions | |
| void | lock () |
| void | unlock () |
Private Attributes | |
| os_mutex_t | mu_ = OS_RECURSIVE_MUTEX_INITIALIZER |
| Mutex that protects. | |
Lightweight locking class for protecting small critical sections.
Properties:
Under FreeRTOS locking a mutex is more than 2x more expensive than locking an Atomic. On desktop OS's Atomic is just a recursive mutex.
Usage: Declare Atomic as a private base class, add a class member variable or a global variable of type Atomic. Then use AtomicHolder to protect the critical sections.
Definition at line 129 of file Atomic.hxx.
|
inline |
Definition at line 132 of file Atomic.hxx.
|
inline |
Definition at line 136 of file Atomic.hxx.
|
private |
Mutex that protects.
NOTE: it is important that this be trivially initialized and the Atomic class have no (nontrivial) constructor. This is the only way to avoid race conditions and initialization order problems during startup.
Definition at line 146 of file Atomic.hxx.