aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-10-20 15:12:11 +0500
committerAbyss777 <abyss@fox5.ru>2017-10-20 15:12:11 +0500
commit91da9fa8e53836e71c36609132c38797317ae9e1 (patch)
tree58121811c5ed26be60e4a8c2c4c45fbc50f40f26 /src
parent39be24a58767c05cb7001e77db1bae56cdbe4445 (diff)
downloadtrackermap-server-91da9fa8e53836e71c36609132c38797317ae9e1.tar.gz
trackermap-server-91da9fa8e53836e71c36609132c38797317ae9e1.tar.bz2
trackermap-server-91da9fa8e53836e71c36609132c38797317ae9e1.zip
Reverted using Queue
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/database/CommandsManager.java14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/org/traccar/database/CommandsManager.java b/src/org/traccar/database/CommandsManager.java
index f9feb927d..cae4ac6f7 100644
--- a/src/org/traccar/database/CommandsManager.java
+++ b/src/org/traccar/database/CommandsManager.java
@@ -22,7 +22,9 @@ 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;
@@ -33,7 +35,7 @@ import org.traccar.model.Position;
public class CommandsManager extends ExtendedObjectManager<Command> {
- private final Map<Long, List<Command>> deviceQueues = new ConcurrentHashMap<>();
+ private final Map<Long, Queue<Command>> deviceQueues = new ConcurrentHashMap<>();
public CommandsManager(DataManager dataManager) {
super(dataManager, Command.class);
@@ -125,18 +127,20 @@ public class CommandsManager extends ExtendedObjectManager<Command> {
return result;
}
- private List<Command> getDeviceQueue(long deviceId) {
+ private Queue<Command> getDeviceQueue(long deviceId) {
if (!deviceQueues.containsKey(deviceId)) {
- deviceQueues.put(deviceId, new ArrayList<Command>());
+ deviceQueues.put(deviceId, new ConcurrentLinkedQueue<Command>());
}
return deviceQueues.get(deviceId);
}
public void sendQueuedCommands(ActiveDevice activeDevice) {
- List<Command> deviceQueue = deviceQueues.get(activeDevice.getDeviceId());
+ Queue<Command> deviceQueue = deviceQueues.get(activeDevice.getDeviceId());
if (deviceQueue != null) {
- for (Command command : deviceQueue) {
+ Command command = deviceQueue.poll();
+ while (command != null) {
activeDevice.sendCommand(command);
+ command = deviceQueue.poll();
}
}
}