Package jade.util
Class InputQueue
- java.lang.Object
-
- jade.util.InputQueue
-
public class InputQueue extends 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 aBehaviour. This Behaviour will be restarted each time an object is inserted in the queue. This class can be effectively used in combination with theEventclass to support a synchronization between the external therad (posting the event in theInputQueue) and the Agent thread (processing the event).- Author:
- Giovanni Caire - TILab
- See Also:
Event
-
-
Constructor Summary
Constructors Constructor Description InputQueue()Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassociate(Behaviour b)Associate thisInputQueueobject with the indicatedBehaviourso that it will be restarted each time a new object is inserted.voidclear()Remove all elements from this queue.Objectget()Extract the first object in the queue (if any).voidput(Object obj)Insert an object into the queue.
-
-
-
Method Detail
-
associate
public void associate(Behaviour b)
Associate thisInputQueueobject with the indicatedBehaviourso that it will be restarted each time a new object is inserted.- Parameters:
b- TheBehaviourto associate.
-
put
public void put(Object obj)
Insert an object into the queue. If there is aBehaviourassociated to thisInputQueueit will be restarted.- Parameters:
obj- The object to insert.
-
get
public Object get()
Extract the first object in the queue (if any).- Returns:
- The first object in the queue or
nullif the queue is empty.
-
clear
public void clear()
Remove all elements from this queue.
-
-