com.limegroup.gnutella.connection
Class SimpleMessageQueue

java.lang.Object
  extended bycom.limegroup.gnutella.connection.MessageQueue
      extended bycom.limegroup.gnutella.connection.SimpleMessageQueue

public class SimpleMessageQueue
extends MessageQueue

Simple LIFO or FIFO message queue.


Field Summary
 
Fields inherited from class com.limegroup.gnutella.connection.MessageQueue
_dropped
 
Constructor Summary
SimpleMessageQueue(int cycle, int timeout, int capacity, boolean lifo)
           
 
Method Summary
protected  Message addInternal(Message m)
          Add m to this, returns any message that had to dropped to make room in a queue.
protected  Message removeNextInternal()
          Same as removeNext, but ignores message age and cycle.
 int size()
          Returns the number of queued messages.
 
Methods inherited from class com.limegroup.gnutella.connection.MessageQueue
add, isEmpty, removeNext, resetCycle, resetDropped
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleMessageQueue

public SimpleMessageQueue(int cycle,
                          int timeout,
                          int capacity,
                          boolean lifo)
Parameters:
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.
capacity - the maximum number of elements this can store.
lifo - true if this is last-in-first-out, false if this is first-in-first-out.
Method Detail

addInternal

protected Message addInternal(Message m)
Description copied from class: MessageQueue
Add m to this, returns any message that had to dropped to make room in a queue.

Specified by:
addInternal in class MessageQueue

removeNextInternal

protected Message removeNextInternal()
Description copied from class: MessageQueue
Same as removeNext, but ignores message age and cycle.

Specified by:
removeNextInternal in class MessageQueue
Returns:
the next message to send, or null if this is empty

size

public int size()
Description copied from class: MessageQueue
Returns the number of queued messages.

Specified by:
size in class MessageQueue