#include <data_lockfree.hpp>
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 DataBuf * | PtrType |
typedef DataBuf | ValueType |
typedef DataBuf *volatile | VolPtrType |
Private Attributes | |
const unsigned int | BUF_LEN |
DataBuf * | data |
VolPtrType | read_ptr |
VolPtrType | write_ptr |
Definition at line 9 of file data_lockfree.hpp.
typedef T hpcl_rtt::DataObjectLockFree< T >::DataType |
The type of the data.
Definition at line 15 of file data_lockfree.hpp.
typedef DataBuf* hpcl_rtt::DataObjectLockFree< T >::PtrType [private] |
Definition at line 48 of file data_lockfree.hpp.
typedef boost::shared_ptr<DataObjectLockFree<T> > hpcl_rtt::DataObjectLockFree< T >::shared_ptr |
Definition at line 16 of file data_lockfree.hpp.
typedef DataBuf hpcl_rtt::DataObjectLockFree< T >::ValueType [private] |
Definition at line 47 of file data_lockfree.hpp.
typedef DataBuf* volatile hpcl_rtt::DataObjectLockFree< T >::VolPtrType [private] |
Definition at line 46 of file data_lockfree.hpp.
hpcl_rtt::DataObjectLockFree< T >::DataObjectLockFree | ( | const T & | initial_value = T() , |
unsigned int | max_threads = 2 |
||
) | [inline] |
Construct a DataObjectLockFree by name.
_name | The name of this DataObject. |
initial_value | The initial value of this DataObject. |
Definition at line 65 of file data_lockfree.hpp.
hpcl_rtt::DataObjectLockFree< T >::~DataObjectLockFree | ( | ) | [inline] |
Definition at line 76 of file data_lockfree.hpp.
virtual void hpcl_rtt::DataObjectLockFree< T >::data_sample | ( | const DataType & | sample | ) | [inline, virtual] |
Definition at line 151 of file data_lockfree.hpp.
virtual DataType hpcl_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.
Definition at line 88 of file data_lockfree.hpp.
virtual void hpcl_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.
pull | A copy of the data. |
Definition at line 97 of file data_lockfree.hpp.
virtual void hpcl_rtt::DataObjectLockFree< T >::Set | ( | const DataType & | push | ) | [inline, virtual] |
Set the data to a certain value (non blocking).
push | The 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 124 of file data_lockfree.hpp.
const unsigned int hpcl_rtt::DataObjectLockFree< T >::BUF_LEN [private] |
Conversion of number of threads to size of buffer.
Definition at line 28 of file data_lockfree.hpp.
DataBuf* hpcl_rtt::DataObjectLockFree< T >::data [private] |
A 3 element Data buffer
Definition at line 56 of file data_lockfree.hpp.
const unsigned int hpcl_rtt::DataObjectLockFree< T >::MAX_THREADS |
The maximum number of threads.
When used in data flow, this is always 2.
Definition at line 23 of file data_lockfree.hpp.
VolPtrType hpcl_rtt::DataObjectLockFree< T >::read_ptr [private] |
Definition at line 50 of file data_lockfree.hpp.
VolPtrType hpcl_rtt::DataObjectLockFree< T >::write_ptr [private] |
Definition at line 51 of file data_lockfree.hpp.