RAUL
0.8.0
|
A realtime safe, (partially) thread safe doubly-linked list. More...
#include <List.hpp>
Classes | |
class | const_iterator |
Realtime safe const iterator for a List. More... | |
class | iterator |
Realtime safe iterator for a List. More... | |
class | Node |
A node in a List. More... | |
Public Member Functions | |
List (size_t size=0, Node *head=NULL, Node *tail=NULL) | |
void | push_back (Node *elem) |
Realtime Safe. More... | |
void | push_back (T &elem) |
NOT Realtime Safe. More... | |
void | append (List< T > &list) |
Append a list to this list. More... | |
void | clear () |
Clear the list, deleting all Nodes contained (but NOT their contents!) More... | |
unsigned | size () const |
Valid only in the write thread. | |
bool | empty () |
Valid for any thread. | |
void | chop_front (List< T > &front, size_t front_size, Node *front_tail) |
Node * | erase (const iterator iter) |
Remove an element from the list using an iterator. More... | |
iterator | find (const T &val) |
Find an element in the list. More... | |
iterator | begin () |
const_iterator | begin () const |
const iterator | end () const |
T & | front () |
const T & | front () const |
Node * | head () |
const Node * | head () const |
A realtime safe, (partially) thread safe doubly-linked list.
Elements can be added safely while another thread is reading the list. Like a typical ringbuffer, this is single-reader single-writer threadsafe only. See documentation for specific functions for specifics.
void Raul::List< T >::push_back | ( | Node * | elem | ) |
Realtime Safe.
Add an element to the list.
Thread safe (may be called while another thread is reading the list). Realtime safe.
Referenced by Raul::Maid::manage().
void Raul::List< T >::push_back | ( | T & | elem | ) |
void Raul::List< T >::append | ( | List< T > & | list | ) |
Append a list to this list.
This operation is fast ( O(1) ). The appended list is not safe to use concurrently with this call. The appended list will be empty after this call.
Thread safe (may be called while another thread is reading the list). Realtime safe.
References Raul::List< T >::size().
void Raul::List< T >::clear | ( | ) |
Clear the list, deleting all Nodes contained (but NOT their contents!)
Not realtime safe.
List< T >::Node * Raul::List< T >::erase | ( | const iterator | iter | ) |
Remove an element from the list using an iterator.
This function is realtime safe - it is the caller's responsibility to delete the returned Node, or there will be a leak. Thread safe (safe to call while another thread reads the list). iter is invalid immediately following this call.
Referenced by Raul::Maid::cleanup().
List< T >::iterator Raul::List< T >::find | ( | const T & | val | ) |
Find an element in the list.
This will return the first element equal to val found in the list.