pion::PionLockFreeQueue< T > Class Template Reference

#include <PionLockFreeQueue.hpp>

List of all members.


Detailed Description

template<typename T>
class pion::PionLockFreeQueue< T >

PionLockFreeQueue: a FIFO queue that is thread-safe and lock-free

Definition at line 51 of file PionLockFreeQueue.hpp.

Public Member Functions

 PionLockFreeQueue (void)
 constructs a new PionLockFreeQueue
virtual ~PionLockFreeQueue ()
 virtual destructor
bool empty (void) const
 returns true if the queue is empty; false if it is not
std::size_t size (void) const
 returns the number of items that are currently in the queue
volatile void clear (void)
void push (const T &t)
bool pop (T &t)

Protected Types

typedef boost::lockfree::tagged_ptr<
QueueNode
QueueNodePtr
 data type for an atomic QueueNode pointer

Protected Member Functions

QueueNodecreateNode (void)
 returns a new queue node item for use in the queue
void destroyNode (QueueNode *node_ptr)
 frees memory for an existing queue node item

Classes

struct  QueueNode
 data structure used to wrap each item in the queue More...


Member Function Documentation

template<typename T>
volatile void pion::PionLockFreeQueue< T >::clear ( void   )  [inline]

clears the queue by removing all remaining items WARNING: this is NOT thread-safe!

Definition at line 117 of file PionLockFreeQueue.hpp.

References pion::PionLockFreeQueue< T >::destroyNode(), pion::PionLockFreeQueue< T >::empty(), and boost::lockfree::tagged_ptr< T >::get_ptr().

Referenced by pion::PionLockFreeQueue< T >::~PionLockFreeQueue().

template<typename T>
bool pion::PionLockFreeQueue< T >::pop ( T &  t  )  [inline]

pops the next item from the top of the queue

Parameters:
t assigned to the item at the top of the queue, if it is not empty
Returns:
true if an item was retrieved, false if the queue is empty

Definition at line 173 of file PionLockFreeQueue.hpp.

References pion::PionLockFreeQueue< T >::QueueNode::data, pion::PionLockFreeQueue< T >::destroyNode(), boost::lockfree::tagged_ptr< T >::get_ptr(), boost::lockfree::likely(), and boost::lockfree::memory_barrier().

template<typename T>
void pion::PionLockFreeQueue< T >::push ( const T &  t  )  [inline]

pushes a new item into the back of the queue

Parameters:
t the item to add to the back of the queue

Definition at line 131 of file PionLockFreeQueue.hpp.

References boost::lockfree::tagged_ptr< T >::cas(), pion::PionLockFreeQueue< T >::createNode(), pion::PionLockFreeQueue< T >::QueueNode::data, boost::lockfree::tagged_ptr< T >::get_ptr(), boost::lockfree::likely(), and boost::lockfree::memory_barrier().


The documentation for this class was generated from the following file:
Generated on Fri Apr 30 14:48:54 2010 for pion-net by  doxygen 1.4.7