A template for created thread-safe variables with an internal critical section controlled each read or write.
Example:
Definition at line 35 of file CThreadSafeVariable.h.
#include <mrpt/synch/CThreadSafeVariable.h>

Public Member Functions | |
| CThreadSafeVariable () | |
| CThreadSafeVariable (const T &init_val) | |
| virtual | ~CThreadSafeVariable () |
| T | get () const |
| Return a copy of the hold variable. More... | |
| void | get (T &out_val) const |
| Return a copy of the hold variable. More... | |
| operator T (void) const | |
| Return a copy of the hold variable. More... | |
| void | set (const T &new_val) |
| Return a copy of the hold variable. More... | |
| void | swap (T &in_out_var) |
| Swap the current value of the hold variable and the passed one, as one atomic operation. More... | |
Private Attributes | |
| CCriticalSection | m_cs |
| T | m_val |
|
inline |
Definition at line 41 of file CThreadSafeVariable.h.
|
inline |
Definition at line 42 of file CThreadSafeVariable.h.
|
inlinevirtual |
Definition at line 44 of file CThreadSafeVariable.h.
|
inline |
Return a copy of the hold variable.
Definition at line 47 of file CThreadSafeVariable.h.
|
inline |
Return a copy of the hold variable.
Definition at line 58 of file CThreadSafeVariable.h.
|
inline |
Return a copy of the hold variable.
Definition at line 65 of file CThreadSafeVariable.h.
References mrpt::synch::CThreadSafeVariable< T >::m_cs, and mrpt::synch::CThreadSafeVariable< T >::m_val.
|
inline |
Return a copy of the hold variable.
Definition at line 72 of file CThreadSafeVariable.h.
|
inline |
Swap the current value of the hold variable and the passed one, as one atomic operation.
Definition at line 79 of file CThreadSafeVariable.h.
|
private |
|
private |
| Page generated by Doxygen 1.8.14 for MRPT 1.5.6 Git: 4c65e8431 Tue Apr 24 08:18:17 2018 +0200 at lun oct 28 01:35:26 CET 2019 |