Classes | Public Types | Public Member Functions | Public Attributes | Private Types | Private Attributes
micros_rtt::DataObjectLockFree< T > Class Template Reference

#include <data_lockfree.hpp>

List of all members.

Classes

struct  DataBuf

Public Types

typedef T DataType
typedef boost::shared_ptr
< DataObjectLockFree< T > > 
shared_ptr

Public Member Functions

virtual void data_sample (const DataType &sample)
 DataObjectLockFree (const T &initial_value=T(), unsigned int max_threads=2)
virtual DataType Get () const
virtual void Get (DataType &pull) const
virtual void Set (const DataType &push)
 ~DataObjectLockFree ()

Public Attributes

const unsigned int MAX_THREADS
 The maximum number of threads.

Private Types

typedef DataBufPtrType
typedef DataBuf ValueType
typedef DataBuf *volatile VolPtrType

Private Attributes

const unsigned int BUF_LEN
DataBufdata
VolPtrType read_ptr
VolPtrType write_ptr

Detailed Description

template<class T>
class micros_rtt::DataObjectLockFree< T >

Definition at line 27 of file data_lockfree.hpp.


Member Typedef Documentation

template<class T>
typedef T micros_rtt::DataObjectLockFree< T >::DataType

The type of the data.

Definition at line 33 of file data_lockfree.hpp.

template<class T>
typedef DataBuf* micros_rtt::DataObjectLockFree< T >::PtrType [private]

Definition at line 66 of file data_lockfree.hpp.

template<class T>
typedef boost::shared_ptr<DataObjectLockFree<T> > micros_rtt::DataObjectLockFree< T >::shared_ptr

Definition at line 34 of file data_lockfree.hpp.

template<class T>
typedef DataBuf micros_rtt::DataObjectLockFree< T >::ValueType [private]

Definition at line 65 of file data_lockfree.hpp.

template<class T>
typedef DataBuf* volatile micros_rtt::DataObjectLockFree< T >::VolPtrType [private]

Definition at line 64 of file data_lockfree.hpp.


Constructor & Destructor Documentation

template<class T>
micros_rtt::DataObjectLockFree< T >::DataObjectLockFree ( const T &  initial_value = T(),
unsigned int  max_threads = 2 
) [inline]

Construct a DataObjectLockFree by name.

Parameters:
_nameThe name of this DataObject.
initial_valueThe initial value of this DataObject.

Definition at line 83 of file data_lockfree.hpp.

template<class T>
micros_rtt::DataObjectLockFree< T >::~DataObjectLockFree ( ) [inline]

Definition at line 94 of file data_lockfree.hpp.


Member Function Documentation

template<class T>
virtual void micros_rtt::DataObjectLockFree< T >::data_sample ( const DataType sample) [inline, virtual]

Definition at line 169 of file data_lockfree.hpp.

template<class T>
virtual DataType micros_rtt::DataObjectLockFree< T >::Get ( ) const [inline, virtual]

Get a copy of the data. This method will allocate memory twice if data is not a value type. Use Get(DataType&) for the non-allocating version.

Returns:
A copy of the data.

Definition at line 106 of file data_lockfree.hpp.

template<class T>
virtual void micros_rtt::DataObjectLockFree< T >::Get ( DataType pull) const [inline, virtual]

Get a copy of the Data (non allocating). If pull has reserved enough memory to store the copy, no memory will be allocated.

Parameters:
pullA copy of the data.

Definition at line 115 of file data_lockfree.hpp.

template<class T>
virtual void micros_rtt::DataObjectLockFree< T >::Set ( const DataType push) [inline, virtual]

Set the data to a certain value (non blocking).

Parameters:
pushThe data which must be set.

This method can not be called concurrently (only one producer). With a minimum of 3 buffers, if the write_ptr+1 field is not occupied, it will remain so because the read_ptr is at write_ptr-1 (and can not increment the counter on write_ptr+1). Hence, no locking is needed.

Definition at line 142 of file data_lockfree.hpp.


Member Data Documentation

template<class T>
const unsigned int micros_rtt::DataObjectLockFree< T >::BUF_LEN [private]

Conversion of number of threads to size of buffer.

Definition at line 46 of file data_lockfree.hpp.

template<class T>
DataBuf* micros_rtt::DataObjectLockFree< T >::data [private]

A 3 element Data buffer

Definition at line 74 of file data_lockfree.hpp.

template<class T>
const unsigned int micros_rtt::DataObjectLockFree< T >::MAX_THREADS

The maximum number of threads.

When used in data flow, this is always 2.

Definition at line 41 of file data_lockfree.hpp.

template<class T>
VolPtrType micros_rtt::DataObjectLockFree< T >::read_ptr [private]

Definition at line 68 of file data_lockfree.hpp.

template<class T>
VolPtrType micros_rtt::DataObjectLockFree< T >::write_ptr [private]

Definition at line 69 of file data_lockfree.hpp.


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


micros_rtt
Author(s): Zaile Jiang , Xiaodong Yi , Minglong Li
autogenerated on Sat Jun 8 2019 19:02:21