Panda3D
Public Member Functions | Protected Member Functions
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

int get_current_queue_size () const
 Returns the current number of things in the queue.
int get_max_queue_size () const
 Returns the maximum size the queue is allowed to grow to.
bool get_overflow_flag () const
 Returns true if the queue has overflowed since the last call to reset_overflow_flag() (implying that some elements have been dropped from the queue), or false otherwise.
void reset_overflow_flag ()
 Resets the overflow flag so that get_overflow_flag() will return false until a new overflow occurs.
void set_max_queue_size (int max_size)
 Sets the maximum size the queue is allowed to grow to.

Protected Member Functions

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.
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 thing_available () const
 Returns true if a thing is available on the queue; call get_thing() to extract the thing.

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 38 of file queuedReturn.h.


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 159 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 183 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 54 of file queuedReturn.I.

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 43 of file queuedReturn.I.

template<class Thing >
bool QueuedReturn< Thing >::get_overflow_flag ( ) const

Returns true if the queue has overflowed since the last call to reset_overflow_flag() (implying that some elements have been dropped from the queue), or false otherwise.

Definition at line 70 of file queuedReturn.I.

template<class Thing>
bool QueuedReturn< Thing >::get_thing ( Thing &  result) [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 136 of file queuedReturn.I.

template<class Thing >
void QueuedReturn< Thing >::reset_overflow_flag ( )

Resets the overflow flag so that get_overflow_flag() will return false until a new overflow occurs.

Definition at line 82 of file queuedReturn.I.

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 30 of file queuedReturn.I.

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 117 of file queuedReturn.I.


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations