aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database/CommandsManager.java
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-10-20 12:56:54 +0500
committerAbyss777 <abyss@fox5.ru>2017-10-20 12:56:54 +0500
commitc4191e726f3f0a8ca83ea47f3316a266e5a22b5d (patch)
tree77218e1ed365ca870105b175563c660e3b97903b /src/org/traccar/database/CommandsManager.java
parenta2f215fe63bd313bfac2a894c170673ccbc252c4 (diff)
downloadtrackermap-server-c4191e726f3f0a8ca83ea47f3316a266e5a22b5d.tar.gz
trackermap-server-c4191e726f3f0a8ca83ea47f3316a266e5a22b5d.tar.bz2
trackermap-server-c4191e726f3f0a8ca83ea47f3316a266e5a22b5d.zip
Use List instead of Queue
Diffstat (limited to 'src/org/traccar/database/CommandsManager.java')
-rw-r--r--src/org/traccar/database/CommandsManager.java14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/org/traccar/database/CommandsManager.java b/src/org/traccar/database/CommandsManager.java
index 624fe56cd..af35965b9 100644
--- a/src/org/traccar/database/CommandsManager.java
+++ b/src/org/traccar/database/CommandsManager.java
@@ -22,9 +22,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
-import java.util.Queue;
import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentLinkedQueue;
import org.traccar.BaseProtocol;
import org.traccar.Context;
@@ -35,7 +33,7 @@ import org.traccar.model.Position;
public class CommandsManager extends ExtendedObjectManager<Command> {
- private final Map<Long, Queue<Command>> deviceQueues = new ConcurrentHashMap<>();
+ private final Map<Long, List<Command>> deviceQueues = new ConcurrentHashMap<>();
public CommandsManager(DataManager dataManager) {
super(dataManager, Command.class);
@@ -127,20 +125,18 @@ public class CommandsManager extends ExtendedObjectManager<Command> {
return result;
}
- private Queue<Command> getDeviceQueue(long deviceId) {
+ private List<Command> getDeviceQueue(long deviceId) {
if (!deviceQueues.containsKey(deviceId)) {
- deviceQueues.put(deviceId, new ConcurrentLinkedQueue<Command>());
+ deviceQueues.put(deviceId, new ArrayList<Command>());
}
return deviceQueues.get(deviceId);
}
public void sendQueuedCommands(ActiveDevice activeDevice) {
- Queue<Command> deviceQueue = deviceQueues.get(activeDevice.getDeviceId());
+ List<Command> deviceQueue = deviceQueues.get(activeDevice.getDeviceId());
if (deviceQueue != null) {
- Command command = deviceQueue.poll();
- while (command != null) {
+ for (Command command : deviceQueue) {
activeDevice.sendCommand(command);
- command = deviceQueue.poll();
}
}
}