16 #ifndef SURGSIM_FRAMEWORK_LOCKEDCONTAINER_H 17 #define SURGSIM_FRAMEWORK_LOCKEDCONTAINER_H 19 #include <boost/thread/mutex.hpp> 20 #include <boost/thread/locks.hpp> 98 void set(
const T& value)
100 boost::lock_guard<boost::mutex> lock(
m_mutex);
112 boost::lock_guard<boost::mutex> lock(
m_mutex);
119 void get(T* value)
const 121 boost::lock_guard<boost::mutex> lock(
m_mutex);
131 boost::lock_guard<boost::mutex> lock(
m_mutex);
146 boost::lock_guard<boost::mutex> lock(
m_mutex);
169 boost::lock_guard<boost::mutex> lock(
m_mutex);
202 #endif // SURGSIM_FRAMEWORK_LOCKEDCONTAINER_H Definition: DriveElementFromInputBehavior.cpp:27
~LockedContainer()
Destroy the container and the data it contains.
Definition: LockedContainer.h:89
bool m_haveNewData
True if there data that has been written, but not yet pulled in by get, take, etc.
Definition: LockedContainer.h:193
LockedContainer(const T &initialValue)
Create the container and the data it contains.
Definition: LockedContainer.h:70
LockedContainer(T &&initialValue)
Create the container and the data it contains.
Definition: LockedContainer.h:81
LockedContainer & operator=(const LockedContainer &)
Prevent assignment.
bool tryGetChanged(T *value) const
Read (copy) the data from the container if it has been modified since the last access.
Definition: LockedContainer.h:144
boost::mutex m_mutex
Mutex for synchronization of set() and get() calls.
Definition: LockedContainer.h:196
void take(T *value)
Move the data out of the container.
Definition: LockedContainer.h:129
A simple thread-safe data container that can support multiple writers and readers.
Definition: LockedContainer.h:54
T m_buffer
Internal buffer.
Definition: LockedContainer.h:190
LockedContainer()
Create the container and the data it contains.
Definition: LockedContainer.h:60
bool tryTakeChanged(T *value)
Move the data out of the container if it has been modified since the last access. ...
Definition: LockedContainer.h:167