|
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) | |
| RTLock (const RTLock &)=delete | |
| RTLock & | operator= (const RTLock &)=delete |
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: { #if USE_THREADS static RTMutex mutex; RTLock lock(mutex); #endif // critical section } Mutex is released when RTLock object is destroyed.