|
LimeWire Consolidated API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.limegroup.gnutella.connection.AbstractMessageQueue
public abstract class AbstractMessageQueue
A priority queue for messages. Subclasses override the add, removeNextInternal, and size template methods to implement different prioritization policies. NOT THREAD SAFE.
This class is designed for speed; hence the somewhat awkward use of resetCycle/extractMax instead of a simple iterator. Likewise, this class has a resetDropped() method instead of returning a (Message, int) pair in removeNext();
| Field Summary | |
|---|---|
protected int |
_dropped
The number of messages dropped since the last call to resetDropped(). |
| Constructor Summary | |
|---|---|
protected |
AbstractMessageQueue(int cycle,
int timeout)
|
| Method Summary | |
|---|---|
void |
add(Message m)
Adds m to this. |
protected abstract Message |
addInternal(Message m)
Add m to this, returns any message that had to dropped to make room in a queue. |
Object |
getDroppedStats()
An inspectable object for dropped messages |
boolean |
isEmpty()
Returns true if this has any queued messages. |
Message |
removeNext()
Removes and returns the next message to send from this during this cycle. |
protected abstract Message |
removeNextInternal()
Same as removeNext, but ignores message age and cycle. |
void |
resetCycle()
Resets the cycle counter used to control removeNext(). |
int |
resetDropped()
Returns the number of dropped messages since the last call to resetDropped(). |
abstract int |
size()
Returns the number of queued messages. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected int _dropped
| Constructor Detail |
|---|
protected AbstractMessageQueue(int cycle,
int timeout)
throws IllegalArgumentException
cycle - the number of messages to return per cycle, i.e., between
calls to resetCycle. This is used to tweak the ratios of various
message types.timeout - the max time to keep queued messages, in milliseconds.
Set this to Integer.MAX_VALUE to avoid timeouts.
IllegalArgumentException| Method Detail |
|---|
public void add(Message m)
add in interface MessageQueuepublic final Object getDroppedStats()
MessageQueue
getDroppedStats in interface MessageQueueprotected abstract Message addInternal(Message m)
public Message removeNext()
removeNext in interface MessageQueueprotected abstract Message removeNextInternal()
public void resetCycle()
resetCycle in interface MessageQueuepublic final int resetDropped()
resetDropped in interface MessageQueuepublic abstract int size()
size in interface MessageQueuepublic boolean isEmpty()
isEmpty in interface MessageQueue
|
LimeWire Consolidated API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||