mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 16:58:40 -04:00
overflow_flag
This commit is contained in:
parent
5924a0b8a4
commit
65e677ad21
@ -19,7 +19,8 @@
|
|||||||
netAddress.h netDatagram.I netDatagram.h \
|
netAddress.h netDatagram.I netDatagram.h \
|
||||||
pprerror.h queuedConnectionListener.I \
|
pprerror.h queuedConnectionListener.I \
|
||||||
queuedConnectionListener.h queuedConnectionManager.h \
|
queuedConnectionListener.h queuedConnectionManager.h \
|
||||||
queuedConnectionReader.h recentConnectionReader.h
|
queuedConnectionReader.h recentConnectionReader.h \
|
||||||
|
queuedReturn.h queuedReturn.I
|
||||||
|
|
||||||
#define INCLUDED_SOURCES \ \
|
#define INCLUDED_SOURCES \ \
|
||||||
config_net.cxx connection.cxx connectionListener.cxx \
|
config_net.cxx connection.cxx connectionListener.cxx \
|
||||||
|
@ -66,6 +66,32 @@ get_current_queue_size() const {
|
|||||||
return size;
|
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
|
// Function: QueuedReturn::Constructor
|
||||||
// Access: Protected
|
// Access: Protected
|
||||||
@ -77,6 +103,7 @@ QueuedReturn() {
|
|||||||
_mutex = PR_NewLock();
|
_mutex = PR_NewLock();
|
||||||
_available = false;
|
_available = false;
|
||||||
_max_queue_size = get_net_max_response_queue();
|
_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);
|
bool enqueue_ok = ((int)_things.size() < _max_queue_size);
|
||||||
if (enqueue_ok) {
|
if (enqueue_ok) {
|
||||||
_things.push_back(thing);
|
_things.push_back(thing);
|
||||||
|
} else {
|
||||||
|
_overflow_flag = true;
|
||||||
}
|
}
|
||||||
_available = true;
|
_available = true;
|
||||||
PR_Unlock(_mutex);
|
PR_Unlock(_mutex);
|
||||||
@ -176,6 +205,9 @@ enqueue_unique_thing(const Thing &thing) {
|
|||||||
// It was already there; return false to indicate this.
|
// It was already there; return false to indicate this.
|
||||||
enqueue_ok = false;
|
enqueue_ok = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
_overflow_flag = true;
|
||||||
}
|
}
|
||||||
_available = true;
|
_available = true;
|
||||||
PR_Unlock(_mutex);
|
PR_Unlock(_mutex);
|
||||||
|
@ -42,6 +42,9 @@ PUBLISHED:
|
|||||||
int get_max_queue_size() const;
|
int get_max_queue_size() const;
|
||||||
int get_current_queue_size() const;
|
int get_current_queue_size() const;
|
||||||
|
|
||||||
|
bool get_overflow_flag() const;
|
||||||
|
void reset_overflow_flag();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QueuedReturn();
|
QueuedReturn();
|
||||||
~QueuedReturn();
|
~QueuedReturn();
|
||||||
@ -57,6 +60,7 @@ private:
|
|||||||
pdeque<Thing> _things;
|
pdeque<Thing> _things;
|
||||||
bool _available;
|
bool _available;
|
||||||
int _max_queue_size;
|
int _max_queue_size;
|
||||||
|
bool _overflow_flag;
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "queuedReturn.I"
|
#include "queuedReturn.I"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user