From f8ba049d565765d26d99a619091a8c75ac43b61f Mon Sep 17 00:00:00 2001 From: James Cotton Date: Sun, 12 Aug 2012 13:16:49 -0500 Subject: [PATCH] AndroidGCS: In the telemetry class use a thread safe queue for transations and removed the synhronized blocks to prevent deadlocks. --- androidgcs/src/org/openpilot/uavtalk/Telemetry.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/androidgcs/src/org/openpilot/uavtalk/Telemetry.java b/androidgcs/src/org/openpilot/uavtalk/Telemetry.java index 2e0b57f41..21525ea14 100644 --- a/androidgcs/src/org/openpilot/uavtalk/Telemetry.java +++ b/androidgcs/src/org/openpilot/uavtalk/Telemetry.java @@ -26,7 +26,6 @@ package org.openpilot.uavtalk; import java.io.IOException; import java.util.ArrayList; -import java.util.LinkedList; import java.util.List; import java.util.ListIterator; import java.util.Observable; @@ -34,6 +33,7 @@ import java.util.Observer; import java.util.Queue; import java.util.Timer; import java.util.TimerTask; +import java.util.concurrent.ConcurrentLinkedQueue; import android.util.Log; @@ -485,7 +485,7 @@ public class Telemetry { * Enqueue the event received from an object. This is the main method that handles all the callbacks * from UAVObjects (due to updates, or update requests) */ - private synchronized void enqueueObjectUpdates(UAVObject obj, int event, boolean allInstances, boolean priority) throws IOException + private void enqueueObjectUpdates(UAVObject obj, int event, boolean allInstances, boolean priority) throws IOException { // Push event into queue if (DEBUG) Log.d(TAG, "Push event into queue for obj " + obj.getName() + " event " + event); @@ -538,7 +538,7 @@ public class Telemetry { * Process events from the object queue * @throws IOException */ - private synchronized void processObjectQueue() throws IOException + private void processObjectQueue() throws IOException { if (DEBUG) Log.d(TAG, "Process object queue - Depth " + objQueue.size() + " priority " + objPriorityQueue.size()); @@ -744,8 +744,8 @@ public class Telemetry { private final UAVTalk utalk; private UAVObject gcsStatsObj; private final List objList = new ArrayList(); - private final Queue objQueue = new LinkedList(); - private final Queue objPriorityQueue = new LinkedList(); + private final Queue objQueue = new ConcurrentLinkedQueue(); + private final Queue objPriorityQueue = new ConcurrentLinkedQueue(); private final ObjectTransactionInfo transInfo = new ObjectTransactionInfo(); private boolean transPending;