Public Member Functions

hamcast::util::single_reader_queue< T > Class Template Reference

A thread safe single-reader-many-writer queue implementation. More...

#include <single_reader_queue.hpp>

List of all members.

Public Member Functions

element_type * pop ()
element_type * try_pop ()
template<typename Duration >
element_type * try_pop (Duration max_wait_duration)
element_type * front ()
void push (element_type *head, element_type *tail)
void push (element_type *new_element)

Detailed Description

template<typename T>
class hamcast::util::single_reader_queue< T >

A thread safe single-reader-many-writer queue implementation.

Parameters:
T The element type of the queue; must provide a next pointer.

Member Function Documentation

template<typename T>
element_type* hamcast::util::single_reader_queue< T >::front (  ) 

Return a pointer to the next element in the queue.

Returns:
NULL if the is empty; otherwise a pointer to the next element.
template<typename T>
element_type* hamcast::util::single_reader_queue< T >::pop (  ) 

Remove the next element in the queue and return it.

Note:
This function blocks on an empty queue.
Returns:
The removed (previously the first) element.
template<typename T>
void hamcast::util::single_reader_queue< T >::push ( element_type *  head,
element_type *  tail 
)

Add the (singly) linked list [head, tail] at the end of the queue.

Parameters:
head The first new element.
tail The last new element.
Warning:
The list [head, tail] should have LIFO order, because it will be read from tail to head.
template<typename T>
void hamcast::util::single_reader_queue< T >::push ( element_type *  new_element  ) 

Add new_element at the end of the queue.

Parameters:
new_element The element that should become the new tail of the queue.
template<typename T>
element_type* hamcast::util::single_reader_queue< T >::try_pop (  ) 

Equal to pop() but returns NULL if the queue is empty.

Returns:
NULL if the queue was empty; otherwise the removed element.
template<typename T>
template<typename Duration >
element_type* hamcast::util::single_reader_queue< T >::try_pop ( Duration  max_wait_duration  ) 

Equal to pop() but blocks at most max_wait_duration and returns NULL on a timeout.

Parameters:
max_wait_duration The maximum wait duration as a boost posix time.
Returns:
NULL on a timeout; otherwise the removed element.

The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator