C++ TargetRTS
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
RTLock Class Reference

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
 

Detailed Description

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
}
Special utility class that allows to protect a piece of code from being accessed by multiple executio...
Definition: RTLock.h:33

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)!


The documentation for this class was generated from the following file: