|
C++ TargetRTS
|
Special utility class that allows to protect a piece of code from being accessed by multiple execution threads at the same time. More...
#include <RTLock.h>
Public Member Functions | |
| RTLock (RTMutex &mutex) | |
Protected Attributes | |
| RTMutex & | _mutex |
Special utility class that allows to protect a piece of code from being accessed by multiple execution threads at the same time.
Critical section starts when RTLock object is constructed, and continues until the end of a C++ block or until a function return statement.
A typical use case is to declare a static mutex and an object of RTLock class in the beginning of a code block or a function:
Mutex is released when RTLock object is destroyed.
NOTE: RTLock uses RTMutex which is not guaranteed to be reentrant on all platforms, and hence RTLock is also not guaranteed to be reentrant. This means the same thread should not lock on a mutex it already has locked (i.e. no recursive locking)!