Honeycomb  0.1
Component-Model Framework
Public Types | Public Member Functions | List of all members
honey::lockfree::SpscDeque< T, Alloc_ > Class Template Reference

Deque that is lock-free only when used by a single producer and consumer, otherwise contention is split between front and back locks. More...

#include <SpscDeque.h>

Inheritance diagram for honey::lockfree::SpscDeque< T, Alloc_ >:
Inheritance graph
[legend]
Collaboration diagram for honey::lockfree::SpscDeque< T, Alloc_ >:
Collaboration graph
[legend]

Public Types

typedef T value_type
 
typedef Alloc_::template rebind< T >::other Alloc
 

Public Member Functions

 SpscDeque (szt size=0, const T &initVal=T(), const Alloc &alloc=Alloc())
 
 ~SpscDeque ()
 
void resize (szt size, const T &initVal=T())
 Resize the deque to contain a number of elements. More...
 
template<class T_ >
void push_front (T_ &&val)
 Insert new element constructed with val at the beginning of the list. More...
 
template<class T_ >
void push_back (T_ &&val)
 Add new element constructed with val onto the end of the list. More...
 
bool pop_front (optional< T & > val=optnull)
 Pop element from the beginning of the list and move it into val. Returns true on success, false if there is no element to pop. More...
 
bool pop_back (optional< T & > val=optnull)
 Pop element from the end of the list and move it into val. Returns true on success, false if there is no element to pop. More...
 
void clear ()
 Remove all elements. More...
 
szt size () const
 Number of elements in deque. More...
 
bool empty () const
 Check whether the deque does not contain any elements. More...
 

Detailed Description

template<class T, class Alloc_ = typename DefaultAllocator<T>::type>
class honey::lockfree::SpscDeque< T, Alloc_ >

Deque that is lock-free only when used by a single producer and consumer, otherwise contention is split between front and back locks.

Automatically expands storage size as needed (requires lock).

Internally maintains a ring-buffer (traversing from head to tail may loop around end of buffer).

Member Typedef Documentation

template<class T , class Alloc_ = typename DefaultAllocator<T>::type>
typedef Alloc_::template rebind<T>::other honey::lockfree::SpscDeque< T, Alloc_ >::Alloc
template<class T , class Alloc_ = typename DefaultAllocator<T>::type>
typedef T honey::lockfree::SpscDeque< T, Alloc_ >::value_type

Constructor & Destructor Documentation

template<class T , class Alloc_ = typename DefaultAllocator<T>::type>
honey::lockfree::SpscDeque< T, Alloc_ >::SpscDeque ( szt  size = 0,
const T &  initVal = T(),
const Alloc alloc = Alloc() 
)
inline
template<class T , class Alloc_ = typename DefaultAllocator<T>::type>
honey::lockfree::SpscDeque< T, Alloc_ >::~SpscDeque ( )
inline

Member Function Documentation

template<class T , class Alloc_ = typename DefaultAllocator<T>::type>
void honey::lockfree::SpscDeque< T, Alloc_ >::clear ( )
inline

Remove all elements.

template<class T , class Alloc_ = typename DefaultAllocator<T>::type>
bool honey::lockfree::SpscDeque< T, Alloc_ >::empty ( ) const
inline

Check whether the deque does not contain any elements.

template<class T , class Alloc_ = typename DefaultAllocator<T>::type>
bool honey::lockfree::SpscDeque< T, Alloc_ >::pop_back ( optional< T & >  val = optnull)
inline

Pop element from the end of the list and move it into val. Returns true on success, false if there is no element to pop.

template<class T , class Alloc_ = typename DefaultAllocator<T>::type>
bool honey::lockfree::SpscDeque< T, Alloc_ >::pop_front ( optional< T & >  val = optnull)
inline

Pop element from the beginning of the list and move it into val. Returns true on success, false if there is no element to pop.

template<class T , class Alloc_ = typename DefaultAllocator<T>::type>
template<class T_ >
void honey::lockfree::SpscDeque< T, Alloc_ >::push_back ( T_ &&  val)
inline

Add new element constructed with val onto the end of the list.

template<class T , class Alloc_ = typename DefaultAllocator<T>::type>
template<class T_ >
void honey::lockfree::SpscDeque< T, Alloc_ >::push_front ( T_ &&  val)
inline

Insert new element constructed with val at the beginning of the list.

template<class T , class Alloc_ = typename DefaultAllocator<T>::type>
void honey::lockfree::SpscDeque< T, Alloc_ >::resize ( szt  size,
const T &  initVal = T() 
)
inline

Resize the deque to contain a number of elements.

template<class T , class Alloc_ = typename DefaultAllocator<T>::type>
szt honey::lockfree::SpscDeque< T, Alloc_ >::size ( ) const
inline

Number of elements in deque.


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