jade.util
Class InputQueue

java.lang.Object
  |
  +--jade.util.InputQueue

public class InputQueue
extends java.lang.Object

This class implements a FIFO queue of objects that can be put and got in a synchronized way. This is useful when an external thread, e.g. a GUI, has to communicate with an agent: The external thread puts objects in the queue and the agent gets and processes them. The queue can be associated to a Behaviour. This Behaviour will be restarted each time an object is inserted in the queue.

Author:
Giovanni Caire - TILab

Constructor Summary
InputQueue()
           
 
Method Summary
 void associate(Behaviour b)
          Associate this InputQueue object with the indicated Behaviour so that it will be restarted each time a new object is inserted.
 java.lang.Object get()
          Extract the first object in the queue (if any).
 void put(java.lang.Object obj)
          Insert an object into the queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InputQueue

public InputQueue()
Method Detail

associate

public void associate(Behaviour b)
Associate this InputQueue object with the indicated Behaviour so that it will be restarted each time a new object is inserted.
Parameters:
b - The Behaviour to associate.

put

public void put(java.lang.Object obj)
Insert an object into the queue. If there is a Behaviour associated to this InputQueue it will be restarted.
Parameters:
obj - The object to insert.

get

public java.lang.Object get()
Extract the first object in the queue (if any).
Returns:
The first object in the queue or null if the queue is empty.