# pion::PionLockedQueue< T, MaxSize, SleepMilliSec > Class Template Reference

`#include <PionLockedQueue.hpp>`

List of all members.

## Detailed Description

### template<typename T, boost::uint32_t MaxSize = 250000, boost::uint32_t SleepMilliSec = 10>
class pion::PionLockedQueue< T, MaxSize, SleepMilliSec >

PionLockedQueue: a thread-safe, two-lock concurrent FIFO queue

Definition at line 43 of file PionLockedQueue.hpp.

## Public Member Functions

| PionLockedQueue (void)
| constructs a new PionLockedQueue
virtual | ~PionLockedQueue ()
| 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
void | clear (void)
| clears the list by removing all remaining items
void | push (const T &t)
bool | pop (T &t, ConsumerThread &thread_info)
bool | pop (T &t)

## Protected Member Functions

QueueNode * | createNode (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
void | initialize (void)
| initializes head and tail pointers for empty queue
bool | dequeue (T &t, boost::uint32_t &version)

## Classes

class | ConsumerThread
| data structure used to manage idle consumer threads waiting for items More...
struct | QueueNode
| data structure used to wrap each item in the queue More...

## Member Function Documentation

template<typename T, boost::uint32_t MaxSize = 250000, boost::uint32_t SleepMilliSec = 10>

bool pion::PionLockedQueue< T, MaxSize, SleepMilliSec >::dequeue | ( | T & | t,
|  | boost::uint32_t & | version |
| ) |  |  | `[inline, protected]`

dequeues 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
  | boost::uint32_t | version number of the item retrieved, or head node if none

Returns:
  true if an item was retrieved; false if the queue is empty

Definition at line 91 of file PionLockedQueue.hpp.

References pion::PionLockedQueue< T, MaxSize, SleepMilliSec >::QueueNode::data, pion::PionLockedQueue< T, MaxSize, SleepMilliSec >::destroyNode(), pion::PionLockedQueue< T, MaxSize, SleepMilliSec >::QueueNode::next, and pion::PionLockedQueue< T, MaxSize, SleepMilliSec >::QueueNode::version.

Referenced by pion::PionLockedQueue< T, MaxSize, SleepMilliSec >::pop().

template<typename T, boost::uint32_t MaxSize = 250000, boost::uint32_t SleepMilliSec = 10>

bool pion::PionLockedQueue< T, MaxSize, SleepMilliSec >::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 296 of file PionLockedQueue.hpp.

References pion::PionLockedQueue< T, MaxSize, SleepMilliSec >::dequeue().

template<typename T, boost::uint32_t MaxSize = 250000, boost::uint32_t SleepMilliSec = 10>

bool pion::PionLockedQueue< T, MaxSize, SleepMilliSec >::pop | ( | T & | t,
|  | ConsumerThread & | thread_info |
| ) |  |  | `[inline]`

pops the next item from the top of the queue. this may cause the calling thread to sleep until an item is available, and will only return when an item has been successfully retrieved or when the thread is stopping

Parameters:

  | t | assigned to the item at the top of the queue
  | thread_info | ConsumerThread object used to manage the thread

Returns:
  true if an item was retrieved, false if the queue is empty

Definition at line 261 of file PionLockedQueue.hpp.

References pion::PionLockedQueue< T, MaxSize, SleepMilliSec >::dequeue(), pion::PionLockedQueue< T, MaxSize, SleepMilliSec >::ConsumerThread::getWakeupTimer(), pion::PionLockedQueue< T, MaxSize, SleepMilliSec >::ConsumerThread::hasWakeupTimer(), pion::PionLockedQueue< T, MaxSize, SleepMilliSec >::ConsumerThread::isRunning(), pion::PionLockedQueue< T, MaxSize, SleepMilliSec >::ConsumerThread::m_next_ptr, pion::PionLockedQueue< T, MaxSize, SleepMilliSec >::ConsumerThread::m_wakeup_event, and pion::PionLockedQueue< T, MaxSize, SleepMilliSec >::QueueNode::version.

template<typename T, boost::uint32_t MaxSize = 250000, boost::uint32_t SleepMilliSec = 10>

void pion::PionLockedQueue< T, MaxSize, SleepMilliSec >::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 215 of file PionLockedQueue.hpp.

References pion::PionLockedQueue< T, MaxSize, SleepMilliSec >::createNode(), pion::PionLockedQueue< T, MaxSize, SleepMilliSec >::QueueNode::data, pion::PionLockedQueue< T, MaxSize, SleepMilliSec >::ConsumerThread::m_next_ptr, pion::PionLockedQueue< T, MaxSize, SleepMilliSec >::ConsumerThread::m_wakeup_event, pion::PionLockedQueue< T, MaxSize, SleepMilliSec >::QueueNode::next, pion::PionLockedQueue< T, MaxSize, SleepMilliSec >::size(), and pion::PionLockedQueue< T, MaxSize, SleepMilliSec >::QueueNode::version.

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

- common/include/pion/PionLockedQueue.hpp