Orocos Real-Time Toolkit  2.6.0
Public Types | Public Member Functions | Public Attributes
RTT::internal::List< T > Class Template Reference

This object represents the default queue implementation used by Orocos objects. More...

#include <rtt/internal/List.hpp>

Inheritance diagram for RTT::internal::List< T >:
RTT::internal::ListLockFree< T >

List of all members.

Public Types

typedef T value_t

Public Member Functions

 List (int qsize, int t=ORONUM_OS_MAX_THREADS)
 Create a queue of fixed size.
size_t capacity () const
 Returns the maximum number of elements this list can hold.
size_t size () const
 Returns the current number of elements in this list.
bool empty () const
 Returns true if this list is empty.
void grow (size_t items=1)
 Grow the capacity to contain at least n additional items.
void shrink (size_t items=1)
 Shrink the capacity with at most n items.
void reserve (size_t lsize)
 Reserve a capacity for this list.
void clear ()
 Clears all elements in the list.
bool append (value_t item)
 Append a single value to the list.
size_t append (const std::vector< T > &items)
 Append a sequence of values to the list.
value_t front () const
 Returns the first element of the list.
value_t back () const
 Returns the last element of the list.
bool erase (value_t item)
 Erase a value from the list.
template<typename Pred >
bool delete_if (Pred pred)
 Erase a value from the list.
template<class Function >
void apply (Function func)
 Apply a function to the elements of the whole list.
template<class Function >
void apply_and_blank (Function func, value_t blank)
 Apply a function to the non-blanked elements of the list.
bool erase_and_blank (value_t item, value_t blank)
 Erase an element from the list and blank it if possible.
template<class Function >
value_t find_if (Function func, value_t blank=value_t())
 Find an item in the list such that func( item ) == true.

Public Attributes

const unsigned int MAX_THREADS
 The maximum number of threads.

Detailed Description

template<class T>
class RTT::internal::List< T >

This object represents the default queue implementation used by Orocos objects.

Definition at line 65 of file List.hpp.


Constructor & Destructor Documentation

template<class T>
RTT::internal::List< T >::List ( int  qsize,
int  t = ORONUM_OS_MAX_THREADS 
) [inline]

Create a queue of fixed size.

Optionally, add the number of threads that may concurrently access this queue.

Definition at line 78 of file List.hpp.


Member Function Documentation

template<class T>
bool RTT::internal::ListLockFree< T >::append ( value_t  item) [inline, inherited]

Append a single value to the list.

This function calls the copy-constructor of item and may call the destructor of item

Parameters:
itemthe value to write
Returns:
false if the list is full.
Note:
This function is only real-time if the destructor or copy-constructor of of T is real-time.

Definition at line 344 of file ListLockFree.hpp.

template<class T>
size_t RTT::internal::ListLockFree< T >::append ( const std::vector< T > &  items) [inline, inherited]

Append a sequence of values to the list.

Parameters:
itemsthe values to append.
Returns:
the number of values written (may be less than d.size())
Note:
This function is only real-time if the destructor and copy-constructor of of T is real-time.

Definition at line 401 of file ListLockFree.hpp.

template<class T>
template<class Function >
void RTT::internal::ListLockFree< T >::apply ( Function  func) [inline, inherited]

Apply a function to the elements of the whole list.

Parameters:
funcThe function to apply.
Note:
Always real-time.

Definition at line 524 of file ListLockFree.hpp.

Referenced by RTT::internal::SignalBase::disconnect().

template<class T>
template<class Function >
void RTT::internal::ListLockFree< T >::apply_and_blank ( Function  func,
value_t  blank 
) [inline, inherited]

Apply a function to the non-blanked elements of the list.

If during an apply_and_blank, the erase_and_blank function is called, that element will not be subject to func if not yet processed. You must not call this function concurrently from multiple threads.

Parameters:
funcThe function to apply.
blankThe 'blank' item. Each item of this list will be compared to this item using operator==(), if it matches, it is considered blank, and func is not applied.
See also:
erase_and_blank
Deprecated:
This complicated function is nowhere used.
Note:
This function is only real-time if the destructor and copy-constructor of of T is real-time.

Definition at line 552 of file ListLockFree.hpp.

template<class T>
size_t RTT::internal::ListLockFree< T >::capacity ( ) const [inline, inherited]

Returns the maximum number of elements this list can hold.

Note:
Always real-time.

Definition at line 178 of file ListLockFree.hpp.

Referenced by RTT::internal::ListLockFree< connection_t >::grow(), and RTT::internal::ListLockFree< connection_t >::reserve().

template<class T>
void RTT::internal::ListLockFree< T >::clear ( ) [inline, inherited]

Clears all elements in the list.

Postcondition:
this->empty() == true
Note:
This function is not real-time if the destructor of of T is not real-time.

Definition at line 316 of file ListLockFree.hpp.

template<class T>
template<typename Pred >
bool RTT::internal::ListLockFree< T >::delete_if ( Pred  pred) [inline, inherited]

Erase a value from the list.

Parameters:
functioneach elements for which pred returns true are removed
Returns:
true if at least one element has been removed
Note:
This function is only real-time if the destructor and copy-constructor of of T is real-time.

Definition at line 480 of file ListLockFree.hpp.

template<class T>
bool RTT::internal::ListLockFree< T >::empty ( ) const [inline, inherited]

Returns true if this list is empty.

Note:
Always real-time.

Definition at line 206 of file ListLockFree.hpp.

Referenced by RTT::internal::SignalBase::destroy(), and RTT::corba::CorbaDispatcher::loop().

template<class T>
bool RTT::internal::ListLockFree< T >::erase ( value_t  item) [inline, inherited]

Erase a value from the list.

Parameters:
itemis to be erased from the list.
Returns:
true if found and erased.
Note:
This function is only real-time if the destructor and copy-constructor of of T is real-time.

Definition at line 438 of file ListLockFree.hpp.

Referenced by RTT::internal::SignalBase::destroy(), RTT::internal::ListLockFree< connection_t >::erase_and_blank(), and RTT::corba::CorbaDispatcher::loop().

template<class T>
bool RTT::internal::ListLockFree< T >::erase_and_blank ( value_t  item,
value_t  blank 
) [inline, inherited]

Erase an element from the list and blank it if possible.

If during an apply_and_blank, the erase_and_blank function is called, that element will not be subject to func if not yet processed. You may call this function concurrently from multiple threads.

Warning:
It is possible that item is being processed within apply_and_blank. In that case the 'blank' operation has no effect.
Parameters:
itemThe item to erase from the list.
blankThe 'blank' item to use to blank item from the list.
See also:
apply_and_blank
Deprecated:
This complicated function is nowhere used.
Note:
This function is only real-time if the destructor and copy-constructor of of T is real-time.

Definition at line 597 of file ListLockFree.hpp.

template<class T>
template<class Function >
value_t RTT::internal::ListLockFree< T >::find_if ( Function  func,
value_t  blank = value_t() 
) [inline, inherited]

Find an item in the list such that func( item ) == true.

Parameters:
blankThe value to return if not found.
Returns:
The item that matches func(item) or blank if none matches.
Note:
This function is only real-time if the copy-constructor of of T is real-time.

Definition at line 626 of file ListLockFree.hpp.

template<class T>
value_t RTT::internal::ListLockFree< T >::front ( ) const [inline, inherited]

Returns the first element of the list.

Note:
This function is only real-time if the copy-constructor of of T is real-time.

Definition at line 373 of file ListLockFree.hpp.

Referenced by RTT::internal::SignalBase::destroy(), and RTT::corba::CorbaDispatcher::loop().

template<class T>
void RTT::internal::ListLockFree< T >::grow ( size_t  items = 1) [inline, inherited]

Grow the capacity to contain at least n additional items.

This method tries to avoid too much re-allocations, by growing a bit more than required every N invocations and growing nothing in between.

Parameters:
itemsThe number of items to at least additionally reserve.
Note:
Almost never real-time.

Definition at line 224 of file ListLockFree.hpp.

template<class T>
void RTT::internal::ListLockFree< T >::reserve ( size_t  lsize) [inline, inherited]

Reserve a capacity for this list.

If you wish to invoke this method concurrently, guard it with a mutex. The other methods may be invoked concurrently with this method.

Parameters:
lsizethe minimal number of items this list will be able to hold. Will not drop below the current capacity() and this method will do nothing if lsize < this->capacity(). @ Not real-time if lsize <= this->capacity().

Definition at line 252 of file ListLockFree.hpp.

Referenced by RTT::internal::ListLockFree< connection_t >::grow(), and RTT::internal::SignalBase::reserve().

template<class T>
void RTT::internal::ListLockFree< T >::shrink ( size_t  items = 1) [inline, inherited]

Shrink the capacity with at most n items.

This method does not actually free memory, it just prevents a (number of) subsequent grow() invocations to allocate more memory.

Parameters:
itemsThe number of items to at most remove from the capacity.
Note:
Always real-time.

Definition at line 238 of file ListLockFree.hpp.

template<class T>
size_t RTT::internal::ListLockFree< T >::size ( ) const [inline, inherited]

Returns the current number of elements in this list.

Note:
Always real-time.

Definition at line 192 of file ListLockFree.hpp.


Member Data Documentation

template<class T>
const unsigned int RTT::internal::ListLockFree< T >::MAX_THREADS [inherited]

The maximum number of threads.

The number of threads which may concurrently access this buffer.

Definition at line 93 of file ListLockFree.hpp.


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