|
|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
package mock.model.commandFactory;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayDeque;
|
|
|
|
|
import java.util.Queue;
|
|
|
|
|
import java.util.concurrent.ConcurrentLinkedDeque;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Wraps multiple commands into a composite to execute queued commands during a frame.
|
|
|
|
|
@ -10,15 +10,15 @@ public class CompositeCommand implements Command {
|
|
|
|
|
private Queue<Command> commands;
|
|
|
|
|
|
|
|
|
|
public CompositeCommand() {
|
|
|
|
|
this.commands = new ArrayDeque<>();
|
|
|
|
|
this.commands = new ConcurrentLinkedDeque<>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void addCommand(Command command) {
|
|
|
|
|
commands.add(command);
|
|
|
|
|
commands.offer(command);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void execute() {
|
|
|
|
|
while(!commands.isEmpty()) commands.remove().execute();
|
|
|
|
|
while(commands.peek() != null) commands.poll().execute();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|