diff --git a/panda/src/net/Sources.pp b/panda/src/net/Sources.pp index 99a676985a..a66095d832 100644 --- a/panda/src/net/Sources.pp +++ b/panda/src/net/Sources.pp @@ -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 \ diff --git a/panda/src/net/queuedReturn.I b/panda/src/net/queuedReturn.I index 28013e44cf..63e4611e52 100644 --- a/panda/src/net/queuedReturn.I +++ b/panda/src/net/queuedReturn.I @@ -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 +bool QueuedReturn:: +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 +void QueuedReturn:: +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); diff --git a/panda/src/net/queuedReturn.h b/panda/src/net/queuedReturn.h index 5b2c1b09be..eba8b3ebf2 100644 --- a/panda/src/net/queuedReturn.h +++ b/panda/src/net/queuedReturn.h @@ -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 _things; bool _available; int _max_queue_size; + bool _overflow_flag; }; #include "queuedReturn.I"