#include <BufferLockFree.hpp>
Public Types | |
typedef BufferInterface< T > ::param_t | param_t |
typedef BufferInterface< T > ::param_t | param_t |
typedef BufferInterface< T > ::reference_t | reference_t |
typedef BufferInterface< T > ::reference_t | reference_t |
typedef BufferInterface< T > ::size_type | size_type |
typedef BufferInterface< T > ::size_type | size_type |
typedef T | value_t |
typedef T | value_t |
Public Member Functions | |
BufferLockFree (unsigned int bufsize, const T &initial_value=T()) | |
BufferLockFree (unsigned int bufsize, const T &initial_value=T()) | |
size_type | capacity () const |
size_type | capacity () const |
void | clear () |
void | clear () |
virtual void | data_sample (const T &sample) |
virtual void | data_sample (const T &sample) |
bool | empty () const |
bool | empty () const |
bool | full () const |
bool | full () const |
size_type | Pop (std::vector< T > &items) |
bool | Pop (reference_t item) |
size_type | Pop (std::vector< T > &items) |
bool | Pop (reference_t item) |
value_t * | PopWithoutRelease () |
value_t * | PopWithoutRelease () |
size_type | Push (const std::vector< T > &items) |
bool | Push (param_t item) |
size_type | Push (const std::vector< T > &items) |
bool | Push (param_t item) |
void | Release (value_t *item) |
void | Release (value_t *item) |
size_type | size () const |
size_type | size () const |
~BufferLockFree () | |
~BufferLockFree () | |
Private Types | |
typedef T | Item |
typedef T | Item |
Private Attributes | |
internal::AtomicMWSRQueue< Item * > | bufs |
internal::TsPool< Item > | mpool |
A Lock-free buffer implementation to read and write data of type T in a FIFO way. No memory allocation is done during read or write. One thread may read and any number of threads may write this buffer.
T | The value type to be stored in the Buffer. Example : BufferLockFree is a buffer which holds values of type A. |
Definition at line 68 of file install/include/rtt/base/BufferLockFree.hpp.
typedef T RTT::base::BufferLockFree< T >::Item [private] |
Definition at line 77 of file rtt/base/BufferLockFree.hpp.
typedef T RTT::base::BufferLockFree< T >::Item [private] |
Definition at line 77 of file install/include/rtt/base/BufferLockFree.hpp.
typedef BufferInterface<T>::param_t RTT::base::BufferLockFree< T >::param_t |
Reimplemented from RTT::base::BufferInterface< T >.
Reimplemented in RTT::base::Buffer< T >, and RTT::base::Buffer< T >.
Definition at line 73 of file rtt/base/BufferLockFree.hpp.
typedef BufferInterface<T>::param_t RTT::base::BufferLockFree< T >::param_t |
Reimplemented from RTT::base::BufferInterface< T >.
Reimplemented in RTT::base::Buffer< T >, and RTT::base::Buffer< T >.
Definition at line 73 of file install/include/rtt/base/BufferLockFree.hpp.
typedef BufferInterface<T>::reference_t RTT::base::BufferLockFree< T >::reference_t |
Reimplemented from RTT::base::BufferInterface< T >.
Reimplemented in RTT::base::Buffer< T >, and RTT::base::Buffer< T >.
Definition at line 72 of file rtt/base/BufferLockFree.hpp.
typedef BufferInterface<T>::reference_t RTT::base::BufferLockFree< T >::reference_t |
Reimplemented from RTT::base::BufferInterface< T >.
Reimplemented in RTT::base::Buffer< T >, and RTT::base::Buffer< T >.
Definition at line 72 of file install/include/rtt/base/BufferLockFree.hpp.
typedef BufferInterface<T>::size_type RTT::base::BufferLockFree< T >::size_type |
Reimplemented from RTT::base::BufferInterface< T >.
Reimplemented in RTT::base::Buffer< T >, and RTT::base::Buffer< T >.
Definition at line 74 of file rtt/base/BufferLockFree.hpp.
typedef BufferInterface<T>::size_type RTT::base::BufferLockFree< T >::size_type |
Reimplemented from RTT::base::BufferInterface< T >.
Reimplemented in RTT::base::Buffer< T >, and RTT::base::Buffer< T >.
Definition at line 74 of file install/include/rtt/base/BufferLockFree.hpp.
typedef T RTT::base::BufferLockFree< T >::value_t |
Reimplemented from RTT::base::BufferInterface< T >.
Reimplemented in RTT::base::Buffer< T >, and RTT::base::Buffer< T >.
Definition at line 75 of file rtt/base/BufferLockFree.hpp.
typedef T RTT::base::BufferLockFree< T >::value_t |
Reimplemented from RTT::base::BufferInterface< T >.
Reimplemented in RTT::base::Buffer< T >, and RTT::base::Buffer< T >.
Definition at line 75 of file install/include/rtt/base/BufferLockFree.hpp.
RTT::base::BufferLockFree< T >::BufferLockFree | ( | unsigned int | bufsize, | |
const T & | initial_value = T() | |||
) | [inline] |
Create a lock-free buffer wich can store bufsize elements.
bufsize | the capacity of the buffer. ' |
Definition at line 86 of file install/include/rtt/base/BufferLockFree.hpp.
RTT::base::BufferLockFree< T >::~BufferLockFree | ( | ) | [inline] |
Definition at line 92 of file install/include/rtt/base/BufferLockFree.hpp.
RTT::base::BufferLockFree< T >::BufferLockFree | ( | unsigned int | bufsize, | |
const T & | initial_value = T() | |||
) | [inline] |
Create a lock-free buffer wich can store bufsize elements.
bufsize | the capacity of the buffer. ' |
Definition at line 86 of file rtt/base/BufferLockFree.hpp.
RTT::base::BufferLockFree< T >::~BufferLockFree | ( | ) | [inline] |
Definition at line 92 of file rtt/base/BufferLockFree.hpp.
size_type RTT::base::BufferLockFree< T >::capacity | ( | ) | const [inline, virtual] |
Returns the maximum number of items that can be stored in the buffer.
Implements RTT::base::BufferBase.
Definition at line 103 of file rtt/base/BufferLockFree.hpp.
size_type RTT::base::BufferLockFree< T >::capacity | ( | ) | const [inline, virtual] |
Returns the maximum number of items that can be stored in the buffer.
Implements RTT::base::BufferBase.
Definition at line 103 of file install/include/rtt/base/BufferLockFree.hpp.
void RTT::base::BufferLockFree< T >::clear | ( | ) | [inline, virtual] |
Clears all contents of this buffer.
Implements RTT::base::BufferBase.
Definition at line 123 of file rtt/base/BufferLockFree.hpp.
void RTT::base::BufferLockFree< T >::clear | ( | ) | [inline, virtual] |
Clears all contents of this buffer.
Implements RTT::base::BufferBase.
Definition at line 123 of file install/include/rtt/base/BufferLockFree.hpp.
virtual void RTT::base::BufferLockFree< T >::data_sample | ( | const T & | sample | ) | [inline, virtual] |
Initializes this buffer with a data sample, such that for dynamical allocated types T, the buffer can reserve place to hold these elements.
Implements RTT::base::BufferInterface< T >.
Definition at line 97 of file rtt/base/BufferLockFree.hpp.
virtual void RTT::base::BufferLockFree< T >::data_sample | ( | const T & | sample | ) | [inline, virtual] |
Initializes this buffer with a data sample, such that for dynamical allocated types T, the buffer can reserve place to hold these elements.
Implements RTT::base::BufferInterface< T >.
Definition at line 97 of file install/include/rtt/base/BufferLockFree.hpp.
bool RTT::base::BufferLockFree< T >::empty | ( | ) | const [inline, virtual] |
Check if this buffer is empty.
Implements RTT::base::BufferBase.
Definition at line 113 of file rtt/base/BufferLockFree.hpp.
bool RTT::base::BufferLockFree< T >::empty | ( | ) | const [inline, virtual] |
Check if this buffer is empty.
Implements RTT::base::BufferBase.
Definition at line 113 of file install/include/rtt/base/BufferLockFree.hpp.
bool RTT::base::BufferLockFree< T >::full | ( | ) | const [inline, virtual] |
Check if this buffer is full.
Implements RTT::base::BufferBase.
Definition at line 118 of file rtt/base/BufferLockFree.hpp.
bool RTT::base::BufferLockFree< T >::full | ( | ) | const [inline, virtual] |
Check if this buffer is full.
Implements RTT::base::BufferBase.
Definition at line 118 of file install/include/rtt/base/BufferLockFree.hpp.
size_type RTT::base::BufferLockFree< T >::Pop | ( | std::vector< T > & | items | ) | [inline, virtual] |
Read the whole buffer.
items | is to be filled with all values in the buffer, with items.begin() the oldest value. |
Implements RTT::base::BufferInterface< T >.
Definition at line 169 of file rtt/base/BufferLockFree.hpp.
bool RTT::base::BufferLockFree< T >::Pop | ( | reference_t | item | ) | [inline, virtual] |
Read the oldest value from the buffer.
item | is to be set with a value from the buffer. |
Implements RTT::base::BufferInterface< T >.
Definition at line 158 of file rtt/base/BufferLockFree.hpp.
size_type RTT::base::BufferLockFree< T >::Pop | ( | std::vector< T > & | items | ) | [inline, virtual] |
Read the whole buffer.
items | is to be filled with all values in the buffer, with items.begin() the oldest value. |
Implements RTT::base::BufferInterface< T >.
Definition at line 169 of file install/include/rtt/base/BufferLockFree.hpp.
bool RTT::base::BufferLockFree< T >::Pop | ( | reference_t | item | ) | [inline, virtual] |
Read the oldest value from the buffer.
item | is to be set with a value from the buffer. |
Implements RTT::base::BufferInterface< T >.
Definition at line 158 of file install/include/rtt/base/BufferLockFree.hpp.
value_t* RTT::base::BufferLockFree< T >::PopWithoutRelease | ( | ) | [inline, virtual] |
Returns a pointer to the first element in the buffer. The pointer is only garanteed to stay valid until the next pop operation.
Note the pointer needs the be released by calling Release on the buffer.
Implements RTT::base::BufferInterface< T >.
Definition at line 181 of file rtt/base/BufferLockFree.hpp.
value_t* RTT::base::BufferLockFree< T >::PopWithoutRelease | ( | ) | [inline, virtual] |
Returns a pointer to the first element in the buffer. The pointer is only garanteed to stay valid until the next pop operation.
Note the pointer needs the be released by calling Release on the buffer.
Implements RTT::base::BufferInterface< T >.
Definition at line 181 of file install/include/rtt/base/BufferLockFree.hpp.
size_type RTT::base::BufferLockFree< T >::Push | ( | const std::vector< T > & | items | ) | [inline, virtual] |
Write a sequence of values to the buffer.
items | the values to write |
Implements RTT::base::BufferInterface< T >.
Definition at line 147 of file rtt/base/BufferLockFree.hpp.
bool RTT::base::BufferLockFree< T >::Push | ( | param_t | item | ) | [inline, virtual] |
Write a single value to the buffer.
item | the value to write |
Implements RTT::base::BufferInterface< T >.
Definition at line 130 of file rtt/base/BufferLockFree.hpp.
size_type RTT::base::BufferLockFree< T >::Push | ( | const std::vector< T > & | items | ) | [inline, virtual] |
Write a sequence of values to the buffer.
items | the values to write |
Implements RTT::base::BufferInterface< T >.
Definition at line 147 of file install/include/rtt/base/BufferLockFree.hpp.
bool RTT::base::BufferLockFree< T >::Push | ( | param_t | item | ) | [inline, virtual] |
Write a single value to the buffer.
item | the value to write |
Implements RTT::base::BufferInterface< T >.
Definition at line 130 of file install/include/rtt/base/BufferLockFree.hpp.
void RTT::base::BufferLockFree< T >::Release | ( | value_t * | item | ) | [inline, virtual] |
Releases the pointer
item | pointer aquired using PopWithoutRelease() |
Implements RTT::base::BufferInterface< T >.
Definition at line 189 of file rtt/base/BufferLockFree.hpp.
void RTT::base::BufferLockFree< T >::Release | ( | value_t * | item | ) | [inline, virtual] |
Releases the pointer
item | pointer aquired using PopWithoutRelease() |
Implements RTT::base::BufferInterface< T >.
Definition at line 189 of file install/include/rtt/base/BufferLockFree.hpp.
size_type RTT::base::BufferLockFree< T >::size | ( | ) | const [inline, virtual] |
Returns the actual number of items that are stored in the buffer.
Implements RTT::base::BufferBase.
Definition at line 108 of file rtt/base/BufferLockFree.hpp.
size_type RTT::base::BufferLockFree< T >::size | ( | ) | const [inline, virtual] |
Returns the actual number of items that are stored in the buffer.
Implements RTT::base::BufferBase.
Definition at line 108 of file install/include/rtt/base/BufferLockFree.hpp.
internal::AtomicMWSRQueue< Item * > RTT::base::BufferLockFree< T >::bufs [private] |
Definition at line 78 of file install/include/rtt/base/BufferLockFree.hpp.
internal::TsPool< Item > RTT::base::BufferLockFree< T >::mpool [mutable, private] |
Definition at line 80 of file install/include/rtt/base/BufferLockFree.hpp.