org.curjent.impl.agent
Class Queue

java.lang.Object
  extended by org.curjent.impl.agent.Queue

final class Queue
extends Object

Implements a doubly linked linked list for agent messages.


Field Summary
private  int capacity
          Current queue capacity.
private  int count
          Current message count.
private  Message head
          Next message for processing or null if empty.
private  int synthetic
          Synthetic message count.
 
Constructor Summary
Queue()
           
 
Method Summary
(package private)  int capacity()
          Returns the queue's capacity.
(package private)  void capacity(int value)
          Sets the queue's capacity.
(package private)  int count()
          Returns the number of queued messages.
(package private)  void dequeue(Message message)
          Removes the given message from the queue.
(package private)  boolean empty()
          Returns true if the queue has no messages.
(package private)  void enqueue(Message message)
          Adds the given message to the end of the queue.
(package private)  void finish(Message message)
          Dequeues the message if necessary and decrements the count.
(package private)  boolean full()
          Returns true if the number of messages has reached this queue's capacity.
(package private)  Message head()
          Returns the head of the queue if any.
(package private)  Message next(Message message)
          Return the next message in the queue or null if the given message is the last message.
 String toString()
          Returns the current message count.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

head

private Message head
Next message for processing or null if empty.


count

private int count
Current message count.


synthetic

private int synthetic
Synthetic message count.


capacity

private int capacity
Current queue capacity.

Constructor Detail

Queue

Queue()
Method Detail

head

Message head()
Returns the head of the queue if any.


empty

boolean empty()
Returns true if the queue has no messages.


full

boolean full()
Returns true if the number of messages has reached this queue's capacity.


count

int count()
Returns the number of queued messages.


capacity

int capacity()
Returns the queue's capacity.


capacity

void capacity(int value)
Sets the queue's capacity.


next

Message next(Message message)
Return the next message in the queue or null if the given message is the last message.


enqueue

void enqueue(Message message)
Adds the given message to the end of the queue.


dequeue

void dequeue(Message message)
Removes the given message from the queue. The count remains unchanged until the message is finished.


finish

void finish(Message message)
Dequeues the message if necessary and decrements the count.


toString

public String toString()
Returns the current message count.

Overrides:
toString in class Object


Copyright 2009-2011 Tom Landon
Apache License 2.0