pion-net  4.0.9
Classes | Public Member Functions | Protected Member Functions
pion::PionLockedQueue< T, MaxSize, SleepMilliSec > Class Template Reference

#include <PionLockedQueue.hpp>

Inherits noncopyable.

List of all members.

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...

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

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

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.


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:
tassigned to the item at the top of the queue, if it is not empty
boost::uint32_tversion 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 >::destroyNode().

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,
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:
tassigned to the item at the top of the queue
thread_infoConsumerThread 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(), and pion::PionLockedQueue< T, MaxSize, SleepMilliSec >::ConsumerThread::isRunning().

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:
tassigned 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>
void pion::PionLockedQueue< T, MaxSize, SleepMilliSec >::push ( const T &  t) [inline]

pushes a new item into the back of the queue

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

Definition at line 215 of file PionLockedQueue.hpp.

References pion::PionLockedQueue< T, MaxSize, SleepMilliSec >::createNode(), and pion::PionLockedQueue< T, MaxSize, SleepMilliSec >::size().


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