16 #ifndef SURGSIM_FRAMEWORK_LOCKEDCONTAINER_H 17 #define SURGSIM_FRAMEWORK_LOCKEDCONTAINER_H 19 #include <boost/thread/mutex.hpp> 20 #include <boost/thread/locks.hpp> 71 m_buffer(initialValue),
82 m_buffer(
std::move(initialValue)),
98 void set(
const T& value)
100 boost::lock_guard<boost::mutex> lock(m_mutex);
102 m_haveNewData =
true;
112 boost::lock_guard<boost::mutex> lock(m_mutex);
113 m_buffer = std::move(value);
114 m_haveNewData =
true;
119 void get(T* value)
const 121 boost::lock_guard<boost::mutex> lock(m_mutex);
122 m_haveNewData =
false;
131 boost::lock_guard<boost::mutex> lock(m_mutex);
132 m_haveNewData =
false;
133 *value = std::move(m_buffer);
146 boost::lock_guard<boost::mutex> lock(m_mutex);
153 m_haveNewData =
false;
169 boost::lock_guard<boost::mutex> lock(m_mutex);
176 m_haveNewData =
false;
177 *value = std::move(m_buffer);
193 mutable bool m_haveNewData;
196 mutable boost::mutex m_mutex;
202 #endif // SURGSIM_FRAMEWORK_LOCKEDCONTAINER_H Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
~LockedContainer()
Destroy the container and the data it contains.
Definition: LockedContainer.h:89
Definition: MockObjects.h:47
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(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
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
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