Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

QueuedReturn< Thing > Class Template Reference

This is the implementation of a family of things that queue up their return values for later retrieval by client code, like QueuedConnectionReader, QueuedConnectionListener, QueuedConnectionManager. More...

#include <queuedReturn.h>

List of all members.

Public Member Functions

void set_max_queue_size (int max_size)
 Sets the maximum size the queue is allowed to grow to.

int get_max_queue_size () const
 Returns the maximum size the queue is allowed to grow to.

int get_current_queue_size () const
 Returns the current number of things in the queue.


Protected Member Functions

 QueuedReturn ()
 ~QueuedReturn ()
bool thing_available () const
 Returns true if a thing is available on the queue; call get_thing() to extract the thing.

bool get_thing (Thing &thing)
 If a previous call to thing_available() returned true, this function will return the thing that has become available.

bool enqueue_thing (const Thing &thing)
 Adds a new thing to the queue for later retrieval.

bool enqueue_unique_thing (const Thing &thing)
 The same as enqueue_thing(), except the queue is first checked that it doesn't already have something like thing.


Private Attributes

PRLock * _mutex
pdeque< Thing > _things
bool _available
int _max_queue_size


Detailed Description

template<class Thing>
class QueuedReturn< Thing >

This is the implementation of a family of things that queue up their return values for later retrieval by client code, like QueuedConnectionReader, QueuedConnectionListener, QueuedConnectionManager.

Definition at line 48 of file queuedReturn.h.


Constructor & Destructor Documentation

template<class Thing>
QueuedReturn< Thing >::QueuedReturn  )  [protected]
 

Definition at line 98 of file queuedReturn.I.

References QueuedReturn< Thing >::_available, and INLINE.

template<class Thing>
QueuedReturn< Thing >::~QueuedReturn  )  [protected]
 

Definition at line 113 of file queuedReturn.I.

References QueuedReturn< Thing >::_available, QueuedReturn< Thing >::_mutex, and QueuedReturn< Thing >::_things.


Member Function Documentation

template<class Thing>
bool QueuedReturn< Thing >::enqueue_thing const Thing &  thing  )  [protected]
 

Adds a new thing to the queue for later retrieval.

Returns true if successful, false if the queue is full (i.e. has reached _max_queue_size).

Definition at line 189 of file queuedReturn.I.

template<class Thing>
bool QueuedReturn< Thing >::enqueue_unique_thing const Thing &  thing  )  [protected]
 

The same as enqueue_thing(), except the queue is first checked that it doesn't already have something like thing.

The return value is true if the enqueue operation was successful, false if the queue was full or the thing was already on the queue.

Definition at line 219 of file queuedReturn.I.

template<class Thing>
int QueuedReturn< Thing >::get_current_queue_size  )  const
 

Returns the current number of things in the queue.

Definition at line 82 of file queuedReturn.I.

References QueuedReturn< Thing >::_mutex.

template<class Thing>
int QueuedReturn< Thing >::get_max_queue_size  )  const
 

Returns the maximum size the queue is allowed to grow to.

See set_max_queue_size().

Definition at line 68 of file queuedReturn.I.

References QueuedReturn< Thing >::_available, QueuedReturn< Thing >::_max_queue_size, QueuedReturn< Thing >::_mutex, and get_net_max_response_queue().

template<class Thing>
bool QueuedReturn< Thing >::get_thing Thing &  thing  )  [protected]
 

If a previous call to thing_available() returned true, this function will return the thing that has become available.

The return value is true if a thing was successfully returned, or false if there was, in fact, no thing available. (This may happen if there are multiple threads accessing the QueuedReturn).

Definition at line 159 of file queuedReturn.I.

References QueuedReturn< Thing >::_available, QueuedReturn< Thing >::_max_queue_size, QueuedReturn< Thing >::_mutex, and QueuedReturn< Thing >::_things.

template<class Thing>
void QueuedReturn< Thing >::set_max_queue_size int  max_size  ) 
 

Sets the maximum size the queue is allowed to grow to.

This is primarily for a sanity check; this is a limit beyond which we can assume something bad has happened.

It's also a crude check against unfortunate seg faults due to the queue filling up and quietly consuming all available memory.

Definition at line 50 of file queuedReturn.I.

References QueuedReturn< Thing >::_max_queue_size.

template<class Thing>
bool QueuedReturn< Thing >::thing_available  )  const [inline, protected]
 

Returns true if a thing is available on the queue; call get_thing() to extract the thing.

Definition at line 129 of file queuedReturn.I.

References QueuedReturn< Thing >::_available, and QueuedReturn< Thing >::_things.


Member Data Documentation

template<class Thing>
bool QueuedReturn< Thing >::_available [private]
 

Definition at line 67 of file queuedReturn.h.

Referenced by QueuedReturn< Thing >::get_max_queue_size(), QueuedReturn< Thing >::get_thing(), QueuedReturn< Thing >::QueuedReturn(), RecentConnectionReader::RecentConnectionReader(), QueuedReturn< Thing >::thing_available(), and QueuedReturn< Thing >::~QueuedReturn().

template<class Thing>
int QueuedReturn< Thing >::_max_queue_size [private]
 

Definition at line 68 of file queuedReturn.h.

Referenced by QueuedReturn< Thing >::get_max_queue_size(), QueuedReturn< Thing >::get_thing(), and QueuedReturn< Thing >::set_max_queue_size().

template<class Thing>
PRLock* QueuedReturn< Thing >::_mutex [private]
 

Definition at line 65 of file queuedReturn.h.

Referenced by QueuedReturn< Thing >::get_current_queue_size(), QueuedReturn< Thing >::get_max_queue_size(), QueuedReturn< Thing >::get_thing(), RecentConnectionReader::RecentConnectionReader(), and QueuedReturn< Thing >::~QueuedReturn().

template<class Thing>
pdeque<Thing> QueuedReturn< Thing >::_things [private]
 

Definition at line 66 of file queuedReturn.h.

Referenced by QueuedReturn< Thing >::get_thing(), QueuedReturn< Thing >::thing_available(), and QueuedReturn< Thing >::~QueuedReturn().


The documentation for this class was generated from the following files:
Generated on Fri May 2 00:54:33 2003 for Panda by doxygen1.3