All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Types | Private Attributes | List of all members
SurgSim::DataStructures::BufferedValue< T > Class Template Reference

BufferedValue is a class to enable a representation of two values for one variable, where both values need to be accessible at the same time, one in a thread safe, single threaded context, the other in a thread unsafe context. More...

#include <SurgSim/DataStructures/BufferedValue.h>

Collaboration diagram for SurgSim::DataStructures::BufferedValue< T >:
Collaboration graph
[legend]

Public Member Functions

 BufferedValue ()
 
 BufferedValue (const T &value)
 
 ~BufferedValue ()
 Destructor. More...
 
void publish ()
 Make the current value the one returned by calls to safeGet. More...
 
T & unsafeGet ()
 Get the value. More...
 
std::shared_ptr< const T > safeGet () const
 Get the buffered value. More...
 

Private Types

typedef boost::shared_lock
< boost::shared_mutex > 
SharedLock
 
typedef boost::unique_lock
< boost::shared_mutex > 
UniqueLock
 

Private Attributes

m_value
 The raw value. More...
 
std::shared_ptr< const T > m_safeValue
 The buffered value. More...
 
boost::shared_mutex m_mutex
 The mutex used to lock for reading and writing. More...
 

Detailed Description

template<class T>
class SurgSim::DataStructures::BufferedValue< T >

BufferedValue is a class to enable a representation of two values for one variable, where both values need to be accessible at the same time, one in a thread safe, single threaded context, the other in a thread unsafe context.

Template Parameters
TType that is used for the value.

Member Typedef Documentation

template<class T>
typedef boost::shared_lock<boost::shared_mutex> SurgSim::DataStructures::BufferedValue< T >::SharedLock
private
template<class T>
typedef boost::unique_lock<boost::shared_mutex> SurgSim::DataStructures::BufferedValue< T >::UniqueLock
private

Constructor & Destructor Documentation

template<class T>
SurgSim::DataStructures::BufferedValue< T >::BufferedValue ( const T &  value)
explicit
Parameters
valueDefault value.

Destructor.

Member Function Documentation

template<class T >
void SurgSim::DataStructures::BufferedValue< T >::publish ( )

Make the current value the one returned by calls to safeGet.

template<class T >
std::shared_ptr< const T > SurgSim::DataStructures::BufferedValue< T >::safeGet ( ) const

Get the buffered value.

Returns
The value at the last call to publish.
template<class T >
T & SurgSim::DataStructures::BufferedValue< T >::unsafeGet ( )

Get the value.

Returns
A reference to the value.

Member Data Documentation

template<class T>
boost::shared_mutex SurgSim::DataStructures::BufferedValue< T >::m_mutex
mutableprivate

The mutex used to lock for reading and writing.

template<class T>
std::shared_ptr<const T> SurgSim::DataStructures::BufferedValue< T >::m_safeValue
private

The buffered value.

template<class T>
T SurgSim::DataStructures::BufferedValue< T >::m_value
private

The raw value.


The documentation for this class was generated from the following files: