hamcast  Version 0.7
Public Member Functions | List of all members
hamcast::util::single_reader_queue< T > Class Template Reference

#include <single_reader_queue.hpp>

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
TThe 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
headThe first new element.
tailThe 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_elementThe 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_durationThe 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: