From 63197bbbd5fd9666251b782ae07cf7c5c2d1ee40 Mon Sep 17 00:00:00 2001 From: "Kristian S. Stangeland" Date: Sat, 29 Sep 2012 23:52:28 +0200 Subject: [PATCH] Add the other cases where we need to know if we're on the main thread or not. --- .../comphenix/protocol/async/AsyncFilterManager.java | 4 +++- .../protocol/async/PacketProcessingQueue.java | 10 ++++++---- .../comphenix/protocol/async/PacketSendingQueue.java | 12 ++++++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/ProtocolLib/src/com/comphenix/protocol/async/AsyncFilterManager.java b/ProtocolLib/src/com/comphenix/protocol/async/AsyncFilterManager.java index f95a9257..569e95d8 100644 --- a/ProtocolLib/src/com/comphenix/protocol/async/AsyncFilterManager.java +++ b/ProtocolLib/src/com/comphenix/protocol/async/AsyncFilterManager.java @@ -143,7 +143,9 @@ public class AsyncFilterManager implements AsynchronousManager { // Start the process getSendingQueue(syncPacket).enqueue(newEvent); - getProcessingQueue(syncPacket).enqueue(newEvent); + + // We know this is occuring on the main thread, to pass TRUE + getProcessingQueue(syncPacket).enqueue(newEvent, true); } @Override diff --git a/ProtocolLib/src/com/comphenix/protocol/async/PacketProcessingQueue.java b/ProtocolLib/src/com/comphenix/protocol/async/PacketProcessingQueue.java index d2ffe29e..af25eaa1 100644 --- a/ProtocolLib/src/com/comphenix/protocol/async/PacketProcessingQueue.java +++ b/ProtocolLib/src/com/comphenix/protocol/async/PacketProcessingQueue.java @@ -53,14 +53,15 @@ class PacketProcessingQueue extends AbstractConcurrentListenerMultimap(INITIAL_CAPACITY, new Comparator() { @@ -46,6 +50,8 @@ class PacketSendingQueue { /** * Invoked when one of the packets have finished processing. + * @param packetUpdated - the packet that has now been updated. + * @param onMainThread - whether or not this is occuring on the main thread. */ public synchronized void signalPacketUpdate(PacketEvent packetUpdated, boolean onMainThread) { // Mark this packet as finished @@ -53,6 +59,11 @@ class PacketSendingQueue { trySendPackets(onMainThread); } + /*** + * Invoked when a list of packet IDs are no longer associated with any listeners. + * @param packetsRemoved - packets that no longer have any listeners. + * @param onMainThread - whether or not this is occuring on the main thread. + */ public synchronized void signalPacketUpdate(List packetsRemoved, boolean onMainThread) { Set lookup = new HashSet(packetsRemoved); @@ -70,6 +81,7 @@ class PacketSendingQueue { /** * Attempt to send any remaining packets. + * @param onMainThread - whether or not this is occuring on the main thread. */ public void trySendPackets(boolean onMainThread) {