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.
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 58 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 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.
References mrpt::synch::CThreadSafeVariable< T >::m_cs, and mrpt::synch::CThreadSafeVariable< T >::m_val.
|
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.
References mrpt::synch::CThreadSafeVariable< T >::m_cs, and mrpt::synch::CThreadSafeVariable< T >::m_val.
|
private |
Definition at line 38 of file CThreadSafeVariable.h.
Referenced by mrpt::synch::CThreadSafeVariable< T >::get(), mrpt::synch::CThreadSafeVariable< T >::operator T(), mrpt::synch::CThreadSafeVariable< T >::set(), and mrpt::synch::CThreadSafeVariable< T >::swap().
|
private |
Definition at line 39 of file CThreadSafeVariable.h.
Referenced by mrpt::synch::CThreadSafeVariable< T >::get(), mrpt::synch::CThreadSafeVariable< T >::operator T(), mrpt::synch::CThreadSafeVariable< T >::set(), and mrpt::synch::CThreadSafeVariable< T >::swap().
Page generated by Doxygen 1.9.5 for MRPT 1.4.0 SVN: at Sun Nov 27 02:56:26 UTC 2022 |