MatLogger2  1.0.0
Library for logging of numeric data to HDF5 MAT-files, which is RT-safe and multithreaded.
Classes | Public Types | Public Member Functions | List of all members
boost::lockfree::spsc_queue< T, A0, A1 > Class Template Reference

The spsc_queue class provides a single-writer/single-reader fifo queue, pushing and popping is wait-free. More...

#include <spsc_queue_logger.hpp>

+ Inheritance diagram for boost::lockfree::spsc_queue< T, A0, A1 >:
+ Collaboration diagram for boost::lockfree::spsc_queue< T, A0, A1 >:

Public Types

typedef T value_type
 
typedef implementation_defined::allocator allocator
 
typedef implementation_defined::size_type size_type
 

Public Member Functions

bool push (T const &t)
 Pushes object t to the ringbuffer. More...
 
bool pop ()
 Pops one object from ringbuffer. More...
 
template<typename U >
boost::enable_if< typename is_convertible< T, U >::type, bool >::type pop (U &ret)
 Pops one object from ringbuffer. More...
 
size_type push (T const *t, size_type size)
 Pushes as many objects from the array t as there is space. More...
 
template<size_type size>
size_type push (T const (&t)[size])
 Pushes as many objects from the array t as there is space available. More...
 
template<typename ConstIterator >
ConstIterator push (ConstIterator begin, ConstIterator end)
 Pushes as many objects from the range [begin, end) as there is space . More...
 
size_type pop (T *ret, size_type size)
 Pops a maximum of size objects from ringbuffer. More...
 
template<size_type size>
size_type pop (T(&ret)[size])
 Pops a maximum of size objects from spsc_queue. More...
 
template<typename OutputIterator >
boost::disable_if< typename is_convertible< T, OutputIterator >::type, size_type >::type pop (OutputIterator it)
 Pops objects to the output iterator it. More...
 
template<typename Functor >
bool consume_one (Functor &f)
 consumes one element via a functor More...
 
template<typename Functor >
bool consume_one (Functor const &f)
 consumes one element via a functor More...
 
template<typename Functor >
size_type consume_all (Functor &f)
 consumes all elements via a functor More...
 
template<typename Functor >
size_type consume_all (Functor const &f)
 consumes all elements via a functor More...
 
size_type read_available () const
 get number of elements that are available for read More...
 
size_type write_available () const
 get write space to write elements More...
 
const T & front () const
 get reference to element in the front of the queue More...
 
T & front ()
 get reference to element in the front of the queue More...
 
void reset (void)
 reset the ringbuffer More...
 
void reset (const T &t)
 reset the ringbuffer More...
 
 spsc_queue (void)
 Constructs a spsc_queue. More...
 
 spsc_queue (const T &t)
 Constructs a spsc_queue. More...
 
template<typename U >
 spsc_queue (typename allocator::template rebind< U >::other const &alloc)
 
 spsc_queue (allocator const &alloc)
 
 spsc_queue (size_type element_count)
 Constructs a spsc_queue for element_count elements. More...
 
template<typename U >
 spsc_queue (size_type element_count, typename allocator::template rebind< U >::other const &alloc)
 
 spsc_queue (size_type element_count, allocator_arg const &alloc)
 

Detailed Description

template<typename T, class A0 = boost::parameter::void_, class A1 = boost::parameter::void_>
class boost::lockfree::spsc_queue< T, A0, A1 >

The spsc_queue class provides a single-writer/single-reader fifo queue, pushing and popping is wait-free.

Policies:

Requirements:

Definition at line 707 of file spsc_queue_logger.hpp.

Member Typedef Documentation

template<typename T, class A0 = boost::parameter::void_, class A1 = boost::parameter::void_>
typedef implementation_defined::allocator boost::lockfree::spsc_queue< T, A0, A1 >::allocator

Definition at line 726 of file spsc_queue_logger.hpp.

template<typename T, class A0 = boost::parameter::void_, class A1 = boost::parameter::void_>
typedef implementation_defined::size_type boost::lockfree::spsc_queue< T, A0, A1 >::size_type

Definition at line 727 of file spsc_queue_logger.hpp.

template<typename T, class A0 = boost::parameter::void_, class A1 = boost::parameter::void_>
typedef T boost::lockfree::spsc_queue< T, A0, A1 >::value_type

Definition at line 725 of file spsc_queue_logger.hpp.

Constructor & Destructor Documentation

template<typename T, class A0 = boost::parameter::void_, class A1 = boost::parameter::void_>
boost::lockfree::spsc_queue< T, A0, A1 >::spsc_queue ( void  )
inline

Constructs a spsc_queue.

Precondition
spsc_queue must be configured to be sized at compile-time

Definition at line 735 of file spsc_queue_logger.hpp.

template<typename T, class A0 = boost::parameter::void_, class A1 = boost::parameter::void_>
boost::lockfree::spsc_queue< T, A0, A1 >::spsc_queue ( const T &  t)
inlineexplicit

Constructs a spsc_queue.

Precondition
spsc_queue must be configured to be sized at compile-time

Definition at line 744 of file spsc_queue_logger.hpp.

template<typename T, class A0 = boost::parameter::void_, class A1 = boost::parameter::void_>
template<typename U >
boost::lockfree::spsc_queue< T, A0, A1 >::spsc_queue ( typename allocator::template rebind< U >::other const &  alloc)
inlineexplicit

Definition at line 753 of file spsc_queue_logger.hpp.

template<typename T, class A0 = boost::parameter::void_, class A1 = boost::parameter::void_>
boost::lockfree::spsc_queue< T, A0, A1 >::spsc_queue ( allocator const &  alloc)
inlineexplicit

Definition at line 759 of file spsc_queue_logger.hpp.

template<typename T, class A0 = boost::parameter::void_, class A1 = boost::parameter::void_>
boost::lockfree::spsc_queue< T, A0, A1 >::spsc_queue ( size_type  element_count)
inlineexplicit

Constructs a spsc_queue for element_count elements.

Precondition
spsc_queue must be configured to be sized at run-time

Definition at line 772 of file spsc_queue_logger.hpp.

template<typename T, class A0 = boost::parameter::void_, class A1 = boost::parameter::void_>
template<typename U >
boost::lockfree::spsc_queue< T, A0, A1 >::spsc_queue ( size_type  element_count,
typename allocator::template rebind< U >::other const &  alloc 
)
inline

Definition at line 779 of file spsc_queue_logger.hpp.

template<typename T, class A0 = boost::parameter::void_, class A1 = boost::parameter::void_>
boost::lockfree::spsc_queue< T, A0, A1 >::spsc_queue ( size_type  element_count,
allocator_arg const &  alloc 
)
inline

Definition at line 785 of file spsc_queue_logger.hpp.

Member Function Documentation

template<typename T, class A0 = boost::parameter::void_, class A1 = boost::parameter::void_>
template<typename Functor >
size_type boost::lockfree::spsc_queue< T, A0, A1 >::consume_all ( Functor &  f)
inline

consumes all elements via a functor

sequentially pops all elements from the queue and applies the functor on each object

Returns
number of elements that are consumed
Note
Thread-safe and non-blocking, if functor is thread-safe and non-blocking

Definition at line 942 of file spsc_queue_logger.hpp.

template<typename T, class A0 = boost::parameter::void_, class A1 = boost::parameter::void_>
template<typename Functor >
size_type boost::lockfree::spsc_queue< T, A0, A1 >::consume_all ( Functor const &  f)
inline

consumes all elements via a functor

sequentially pops all elements from the queue and applies the functor on each object

Returns
number of elements that are consumed
Note
Thread-safe and non-blocking, if functor is thread-safe and non-blocking

Definition at line 949 of file spsc_queue_logger.hpp.

template<typename T, class A0 = boost::parameter::void_, class A1 = boost::parameter::void_>
template<typename Functor >
bool boost::lockfree::spsc_queue< T, A0, A1 >::consume_one ( Functor &  f)
inline

consumes one element via a functor

pops one element from the queue and applies the functor on this object

Returns
true, if one element was consumed
Note
Thread-safe and non-blocking, if functor is thread-safe and non-blocking

Definition at line 921 of file spsc_queue_logger.hpp.

template<typename T, class A0 = boost::parameter::void_, class A1 = boost::parameter::void_>
template<typename Functor >
bool boost::lockfree::spsc_queue< T, A0, A1 >::consume_one ( Functor const &  f)
inline

consumes one element via a functor

pops one element from the queue and applies the functor on this object

Returns
true, if one element was consumed
Note
Thread-safe and non-blocking, if functor is thread-safe and non-blocking

Definition at line 928 of file spsc_queue_logger.hpp.

template<typename T, class A0 = boost::parameter::void_, class A1 = boost::parameter::void_>
const T& boost::lockfree::spsc_queue< T, A0, A1 >::front ( void  ) const
inline

get reference to element in the front of the queue

Availability of front element can be checked using read_available().

Precondition
only one thread is allowed to check front element
read_available() > 0. If ringbuffer is empty, it's undefined behaviour to invoke this method.
Returns
reference to the first element in the queue
Note
Thread-safe and wait-free

Definition at line 986 of file spsc_queue_logger.hpp.

template<typename T, class A0 = boost::parameter::void_, class A1 = boost::parameter::void_>
T& boost::lockfree::spsc_queue< T, A0, A1 >::front ( void  )
inline

get reference to element in the front of the queue

Availability of front element can be checked using read_available().

Precondition
only one thread is allowed to check front element
read_available() > 0. If ringbuffer is empty, it's undefined behaviour to invoke this method.
Returns
reference to the first element in the queue
Note
Thread-safe and wait-free

Definition at line 993 of file spsc_queue_logger.hpp.

template<typename T, class A0 = boost::parameter::void_, class A1 = boost::parameter::void_>
bool boost::lockfree::spsc_queue< T, A0, A1 >::pop ( )
inline

Pops one object from ringbuffer.

Precondition
only one thread is allowed to pop data to the spsc_queue
Postcondition
if ringbuffer is not empty, object will be discarded.
Returns
true, if the pop operation is successful, false if ringbuffer was empty.
Note
Thread-safe and wait-free

Definition at line 813 of file spsc_queue_logger.hpp.

template<typename T, class A0 = boost::parameter::void_, class A1 = boost::parameter::void_>
template<typename U >
boost::enable_if<typename is_convertible<T, U>::type, bool>::type boost::lockfree::spsc_queue< T, A0, A1 >::pop ( U &  ret)
inline

Pops one object from ringbuffer.

Precondition
only one thread is allowed to pop data to the spsc_queue
Postcondition
if ringbuffer is not empty, object will be copied to ret.
Returns
true, if the pop operation is successful, false if ringbuffer was empty.
Note
Thread-safe and wait-free

Definition at line 829 of file spsc_queue_logger.hpp.

template<typename T, class A0 = boost::parameter::void_, class A1 = boost::parameter::void_>
size_type boost::lockfree::spsc_queue< T, A0, A1 >::pop ( T *  ret,
size_type  size 
)
inline

Pops a maximum of size objects from ringbuffer.

Precondition
only one thread is allowed to pop data to the spsc_queue
Returns
number of popped items
Note
Thread-safe and wait-free

Definition at line 880 of file spsc_queue_logger.hpp.

template<typename T, class A0 = boost::parameter::void_, class A1 = boost::parameter::void_>
template<size_type size>
size_type boost::lockfree::spsc_queue< T, A0, A1 >::pop ( T(&)  ret[size])
inline

Pops a maximum of size objects from spsc_queue.

Precondition
only one thread is allowed to pop data to the spsc_queue
Returns
number of popped items
Note
Thread-safe and wait-free

Definition at line 893 of file spsc_queue_logger.hpp.

template<typename T, class A0 = boost::parameter::void_, class A1 = boost::parameter::void_>
template<typename OutputIterator >
boost::disable_if<typename is_convertible<T, OutputIterator>::type, size_type>::type boost::lockfree::spsc_queue< T, A0, A1 >::pop ( OutputIterator  it)
inline

Pops objects to the output iterator it.

Precondition
only one thread is allowed to pop data to the spsc_queue
Returns
number of popped items
Note
Thread-safe and wait-free

Definition at line 907 of file spsc_queue_logger.hpp.

template<typename T, class A0 = boost::parameter::void_, class A1 = boost::parameter::void_>
bool boost::lockfree::spsc_queue< T, A0, A1 >::push ( T const &  t)
inline

Pushes object t to the ringbuffer.

Precondition
only one thread is allowed to push data to the spsc_queue
Postcondition
object will be pushed to the spsc_queue, unless it is full.
Returns
true, if the push operation is successful.
Note
Thread-safe and wait-free

Definition at line 800 of file spsc_queue_logger.hpp.

template<typename T, class A0 = boost::parameter::void_, class A1 = boost::parameter::void_>
size_type boost::lockfree::spsc_queue< T, A0, A1 >::push ( T const *  t,
size_type  size 
)
inline

Pushes as many objects from the array t as there is space.

Precondition
only one thread is allowed to push data to the spsc_queue
Returns
number of pushed items
Note
Thread-safe and wait-free

Definition at line 842 of file spsc_queue_logger.hpp.

template<typename T, class A0 = boost::parameter::void_, class A1 = boost::parameter::void_>
template<size_type size>
size_type boost::lockfree::spsc_queue< T, A0, A1 >::push ( T const (&)  t[size])
inline

Pushes as many objects from the array t as there is space available.

Precondition
only one thread is allowed to push data to the spsc_queue
Returns
number of pushed items
Note
Thread-safe and wait-free

Definition at line 855 of file spsc_queue_logger.hpp.

template<typename T, class A0 = boost::parameter::void_, class A1 = boost::parameter::void_>
template<typename ConstIterator >
ConstIterator boost::lockfree::spsc_queue< T, A0, A1 >::push ( ConstIterator  begin,
ConstIterator  end 
)
inline

Pushes as many objects from the range [begin, end) as there is space .

Precondition
only one thread is allowed to push data to the spsc_queue
Returns
iterator to the first element, which has not been pushed
Note
Thread-safe and wait-free

Definition at line 868 of file spsc_queue_logger.hpp.

template<typename T, class A0 = boost::parameter::void_, class A1 = boost::parameter::void_>
size_type boost::lockfree::spsc_queue< T, A0, A1 >::read_available ( ) const
inline

get number of elements that are available for read

Returns
number of available elements that can be popped from the spsc_queue
Note
Thread-safe and wait-free, should only be called from the producer thread

Definition at line 960 of file spsc_queue_logger.hpp.

template<typename T, class A0 = boost::parameter::void_, class A1 = boost::parameter::void_>
void boost::lockfree::spsc_queue< T, A0, A1 >::reset ( void  )
inline

reset the ringbuffer

Note
Not thread-safe

Definition at line 1003 of file spsc_queue_logger.hpp.

template<typename T, class A0 = boost::parameter::void_, class A1 = boost::parameter::void_>
void boost::lockfree::spsc_queue< T, A0, A1 >::reset ( const T &  t)
inline

reset the ringbuffer

Note
Not thread-safe

Definition at line 1021 of file spsc_queue_logger.hpp.

template<typename T, class A0 = boost::parameter::void_, class A1 = boost::parameter::void_>
size_type boost::lockfree::spsc_queue< T, A0, A1 >::write_available ( ) const
inline

get write space to write elements

Returns
number of elements that can be pushed to the spsc_queue
Note
Thread-safe and wait-free, should only be called from the consumer thread

Definition at line 971 of file spsc_queue_logger.hpp.


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