Go to the documentation of this file.
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);
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
void set(T &&value)
Write (move) new data into the container.
Definition: LockedContainer.h:110
bool m_haveNewData
True if there data that has been written, but not yet pulled in by get, take, etc.
Definition: LockedContainer.h:193
boost::mutex m_mutex
Mutex for synchronization of set() and get() calls.
Definition: LockedContainer.h:196
Definition: CompoundShapeToGraphics.cpp:29
A simple thread-safe data container that can support multiple writers and readers.
Definition: LockedContainer.h:54
LockedContainer(T &&initialValue)
Create the container and the data it contains.
Definition: LockedContainer.h:81
void get(T *value) const
Read (copy) the data from the container.
Definition: LockedContainer.h:119
void set(const T &value)
Write (copy) new data into the container.
Definition: LockedContainer.h:98
~LockedContainer()
Destroy the container and the data it contains.
Definition: LockedContainer.h:89
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
LockedContainer & operator=(const LockedContainer &)
Prevent assignment.
LockedContainer()
Create the container and the data it contains.
Definition: LockedContainer.h:60
T m_buffer
Internal buffer.
Definition: LockedContainer.h:190
bool tryTakeChanged(T *value)
Move the data out of the container if it has been modified since the last access.
Definition: LockedContainer.h:167
LockedContainer(const T &initialValue)
Create the container and the data it contains.
Definition: LockedContainer.h:70
void take(T *value)
Move the data out of the container.
Definition: LockedContainer.h:129