activemq::util::Queue< T > Class Template Reference

#include <Queue.h>

Inheritance diagram for activemq::util::Queue< T >:

activemq::concurrent::Synchronizable List of all members.

Public Member Functions

 Queue (void)
virtual ~Queue (void)
T & front (void)
const T & front (void) const
T & back (void)
const T & back (void) const
void push (const T &t)
pop (void)
size_t size (void) const
bool empty (void) const
virtual void lock () throw ( exceptions::ActiveMQException )
virtual void unlock () throw ( exceptions::ActiveMQException )
virtual void wait () throw ( exceptions::ActiveMQException )
virtual void wait (unsigned long millisecs) throw ( exceptions::ActiveMQException )
virtual void notify () throw ( exceptions::ActiveMQException )
virtual void notifyAll () throw ( exceptions::ActiveMQException )

Static Public Member Functions

static const T & getSafeValue (void)

Private Attributes

std::queue< T > queue
concurrent::Mutex mutex

Static Private Attributes

static T safe

Detailed Description

template<typename T>
class activemq::util::Queue< T >

The Queue class accepts messages with an psuh(m) command where m is the message to be queued. It destructively returns the message with pop(). pop() returns messages in the order they were enqueued.

Queue is implemented with an instance of the STL queue object. The interface is essentially the same as that of the STL queue except that the pop method actually reaturns a reference to the element popped. This frees the app from having to call the front method before calling pop.

Queue<string> sq; // make a queue to hold string messages sq.push(s); // enqueues a message m string s = sq.pop(); // dequeues a message

= DESIGN CONSIDERATIONS

The Queue class inherits from the Synchronizable interface and provides methods for locking and unlocking this queue as well as waiting on this queue. In a multi-threaded app this can allow for multiple threads to be reading from and writing to the same Queue.

Clients should consider that in a multiple threaded app it is possible that items could be placed on the queue faster than you are taking them off, so protection should be placed in your polling loop to ensure that you don't get stuck there.


Constructor & Destructor Documentation

template<typename T>
activemq::util::Queue< T >::Queue void   ) 
 

template<typename T>
activemq::util::Queue< T >::~Queue void   )  [virtual]
 


Member Function Documentation

template<typename T>
const T & activemq::util::Queue< T >::back void   )  const
 

Returns a Reference to the element at the tail of the queue

Returns:
reference to a queue type object or (safe)

template<typename T>
T & activemq::util::Queue< T >::back void   ) 
 

Returns a Reference to the element at the tail of the queue

Returns:
reference to a queue type object or (safe)

template<typename T>
bool activemq::util::Queue< T >::empty void   )  const [inline]
 

Checks if this Queue is currently empty

Returns:
boolean indicating queue emptiness

template<typename T>
const T & activemq::util::Queue< T >::front void   )  const
 

Returns a Reference to the element at the head of the queue

Returns:
reference to a queue type object or (safe)

template<typename T>
T & activemq::util::Queue< T >::front void   ) 
 

Returns a Reference to the element at the head of the queue

Returns:
reference to a queue type object or (safe)

template<typename T>
static const T& activemq::util::Queue< T >::getSafeValue void   )  [inline, static]
 

Fetch a reference to the safe value this object will return when there is nothing to fetch from the queue.

Returns:
Reference to this Queues safe object

template<typename T>
virtual void activemq::util::Queue< T >::lock  )  throw ( exceptions::ActiveMQException ) [inline, virtual]
 

Locks the object.

Implements activemq::concurrent::Synchronizable.

template<typename T>
virtual void activemq::util::Queue< T >::notify  )  throw ( exceptions::ActiveMQException ) [inline, virtual]
 

Signals a waiter on this object that it can now wake up and continue. Must have this object locked before calling.

Implements activemq::concurrent::Synchronizable.

template<typename T>
virtual void activemq::util::Queue< T >::notifyAll  )  throw ( exceptions::ActiveMQException ) [inline, virtual]
 

Signals the waiters on this object that it can now wake up and continue. Must have this object locked before calling.

Implements activemq::concurrent::Synchronizable.

template<typename T>
T activemq::util::Queue< T >::pop void   ) 
 

Removes and returns the element that is at the Head of the queue

Returns:
reference to a queue type object or (safe)

template<typename T>
void activemq::util::Queue< T >::push const T &  t  ) 
 

Places a new Object at the Tail of the queue

Parameters:
t - Queue Object Type reference.

template<typename T>
size_t activemq::util::Queue< T >::size void   )  const [inline]
 

Gets the Number of elements currently in the Queue

Returns:
Queue Size

template<typename T>
virtual void activemq::util::Queue< T >::unlock  )  throw ( exceptions::ActiveMQException ) [inline, virtual]
 

Unlocks the object.

Implements activemq::concurrent::Synchronizable.

template<typename T>
virtual void activemq::util::Queue< T >::wait unsigned long  millisecs  )  throw ( exceptions::ActiveMQException ) [inline, virtual]
 

Waits on a signal from this object, which is generated by a call to Notify. Must have this object locked before calling. This wait will timeout after the specified time interval.

Parameters:
millisecs time to wait, or WAIT_INIFINITE
Exceptions:
ActiveMQException 

Implements activemq::concurrent::Synchronizable.

template<typename T>
virtual void activemq::util::Queue< T >::wait  )  throw ( exceptions::ActiveMQException ) [inline, virtual]
 

Waits on a signal from this object, which is generated by a call to Notify. Must have this object locked before calling.

Implements activemq::concurrent::Synchronizable.


Member Data Documentation

template<typename T>
concurrent::Mutex activemq::util::Queue< T >::mutex [private]
 

template<typename T>
std::queue<T> activemq::util::Queue< T >::queue [private]
 

template<typename T>
T activemq::util::Queue< T >::safe [static, private]
 


The documentation for this class was generated from the following file:
Generated on Thu Aug 3 18:03:33 2006 for activemq-cpp by  doxygen 1.4.5