From c4191e726f3f0a8ca83ea47f3316a266e5a22b5d Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Fri, 20 Oct 2017 12:56:54 +0500 Subject: Use List instead of Queue --- src/org/traccar/database/CommandsManager.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'src/org/traccar') 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 { - private final Map> deviceQueues = new ConcurrentHashMap<>(); + private final Map> deviceQueues = new ConcurrentHashMap<>(); public CommandsManager(DataManager dataManager) { super(dataManager, Command.class); @@ -127,20 +125,18 @@ public class CommandsManager extends ExtendedObjectManager { return result; } - private Queue getDeviceQueue(long deviceId) { + private List getDeviceQueue(long deviceId) { if (!deviceQueues.containsKey(deviceId)) { - deviceQueues.put(deviceId, new ConcurrentLinkedQueue()); + deviceQueues.put(deviceId, new ArrayList()); } return deviceQueues.get(deviceId); } public void sendQueuedCommands(ActiveDevice activeDevice) { - Queue deviceQueue = deviceQueues.get(activeDevice.getDeviceId()); + List 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(); } } } -- cgit v1.2.3