overflow_flag

This commit is contained in:
David Rose 2004-06-28 22:23:17 +00:00
parent 5924a0b8a4
commit 65e677ad21
3 changed files with 38 additions and 1 deletions

View File

@ -19,7 +19,8 @@
netAddress.h netDatagram.I netDatagram.h \
pprerror.h queuedConnectionListener.I \
queuedConnectionListener.h queuedConnectionManager.h \
queuedConnectionReader.h recentConnectionReader.h
queuedConnectionReader.h recentConnectionReader.h \
queuedReturn.h queuedReturn.I
#define INCLUDED_SOURCES \ \
config_net.cxx connection.cxx connectionListener.cxx \

View File

@ -66,6 +66,32 @@ get_current_queue_size() const {
return size;
}
////////////////////////////////////////////////////////////////////
// Function: QueuedReturn::get_overflow_flag
// Access: Published
// Description: 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.
////////////////////////////////////////////////////////////////////
template<class Thing>
bool QueuedReturn<Thing>::
get_overflow_flag() const {
return _overflow_flag;
}
////////////////////////////////////////////////////////////////////
// Function: QueuedReturn::reset_overflow_flag
// Access: Published
// Description: Resets the overflow flag so that get_overflow_flag()
// will return false until a new overflow occurs.
////////////////////////////////////////////////////////////////////
template<class Thing>
void QueuedReturn<Thing>::
reset_overflow_flag() {
_overflow_flag = false;
}
////////////////////////////////////////////////////////////////////
// Function: QueuedReturn::Constructor
// Access: Protected
@ -77,6 +103,7 @@ QueuedReturn() {
_mutex = PR_NewLock();
_available = false;
_max_queue_size = get_net_max_response_queue();
_overflow_flag = false;
}
////////////////////////////////////////////////////////////////////
@ -147,6 +174,8 @@ enqueue_thing(const Thing &thing) {
bool enqueue_ok = ((int)_things.size() < _max_queue_size);
if (enqueue_ok) {
_things.push_back(thing);
} else {
_overflow_flag = true;
}
_available = true;
PR_Unlock(_mutex);
@ -176,6 +205,9 @@ enqueue_unique_thing(const Thing &thing) {
// It was already there; return false to indicate this.
enqueue_ok = false;
}
} else {
_overflow_flag = true;
}
_available = true;
PR_Unlock(_mutex);

View File

@ -42,6 +42,9 @@ PUBLISHED:
int get_max_queue_size() const;
int get_current_queue_size() const;
bool get_overflow_flag() const;
void reset_overflow_flag();
protected:
QueuedReturn();
~QueuedReturn();
@ -57,6 +60,7 @@ private:
pdeque<Thing> _things;
bool _available;
int _max_queue_size;
bool _overflow_flag;
};
#include "queuedReturn.I"