public class EventQueue extends ItemBuffer<Event> implements MessageReceiver
Modifier and Type | Field and Description |
---|---|
private AbstractProcess |
agent |
private boolean |
usePriorities |
Modifier | Constructor and Description |
---|---|
protected |
EventQueue(AbstractProcess agent)
Constructs and empty EventQueue associating it with an agent that will
be interrupted whenever an event is queued.
|
Modifier and Type | Method and Description |
---|---|
protected Event |
getItem()
Returns the first object in the list
|
MLMessage |
getMessageInReplyTo(MLMessage msg) |
boolean |
getUsePriority() |
protected int |
insertPos(Event item)
Override of the template method change the behaviour of
method putItem().
|
void |
messageReceived(MLMessage message)
This method will be envoked when a message has been received,
message
contains source information and content of the message. |
protected void |
notifyNewItem(Event e)
This method is called whenever
ItemBuffer.putItem(Object) is called. |
void |
putItem(Event event)
Inserts an Event at the end of the buffer and checks to see if there
is a thread waiting on the message (in which case, it notifies the thread).
|
boolean |
setUsePriority(boolean usePriority)
Set to true to use priority fields in messages to control the order that
messages are dequeued from the buffer.
|
contains, isEmpty, iterator, peek, remove, size, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
private boolean usePriorities
private AbstractProcess agent
protected EventQueue(AbstractProcess agent)
agent
- public void putItem(Event event)
putItem
in class ItemBuffer<Event>
event
- message to insertprotected Event getItem()
ItemBuffer
getItem
in class ItemBuffer<Event>
protected void notifyNewItem(Event e)
ItemBuffer
ItemBuffer.putItem(Object)
is called. Subclasses
should override to provide the actual behaviour. This method does nothing.notifyNewItem
in class ItemBuffer<Event>
e
- the item that was queuedprotected int insertPos(Event item)
insertPos
in class ItemBuffer<Event>
item
- the item to decide where to put in the bufferpublic boolean setUsePriority(boolean usePriority)
usePriority
- set to true to make this a priority queue, false for a simple FIFO queue.public boolean getUsePriority()
public void messageReceived(MLMessage message)
MessageReceiver
message
contains source information and content of the message.messageReceived
in interface MessageReceiver
message
- message receivedIPMessage