nl.tudelft.goal.ut2004.actions
Class ActionQueue
java.lang.Object
nl.tudelft.goal.ut2004.actions.ActionQueue
public final class ActionQueue
- extends Object
Smart queue for actions.
There is a limited bandwidth to transfer actions between GOAL and the
UT2004Bot. GOAL will send actions at a high rate and could saturate the
queue. To prevent this we check which actions are in the queue before adding
a new action.
There are three possible scenarios:
- If the effects of a new action would cancel out the effects of an action
in the queue, the queued action is discarded.
- If the effects of a new action have no effect on an action in the queue,
the action is put in.
- If an action in the queue means the new action has no effect, the new
action id discarded.
- Author:
- mpkorstanje
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ActionQueue
public ActionQueue(int capacity)
put
public void put(Action action)
throws InterruptedException
- Puts an action on the queue. If the queue is full this method will block.
The action is added intelligently to the queue. Should the results of
this action happened to override or cancel out an action already in the
queue the action in the queue will be removed.
- Parameters:
action
-
- Throws:
InterruptedException
drain
public Collection<Action> drain()
- Drains all actions from the queue.
- Returns:
- a collection of actions to be executed.
Copyright © 2013 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.