1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2025-09-10 18:59:41 +02:00

Reuse empty slots in the collection to store new listeners/collectors. Fixed by Alex. :) SMACK-149

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@4340 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Gaston Dombiak 2006-07-10 16:51:56 +00:00 committed by gato
parent 97b80ac8da
commit f9ecbb3297
2 changed files with 119 additions and 59 deletions

View file

@ -20,8 +20,8 @@
package org.jivesoftware.smack;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.packet.Packet;
import java.util.LinkedList;
@ -63,10 +63,6 @@ public class PacketCollector {
this.packetReader = packetReader;
this.packetFilter = packetFilter;
this.resultQueue = new LinkedList();
// Add the collector to the packet reader's list of active collector.
synchronized (packetReader.collectors) {
packetReader.collectors.add(this);
}
}
/**
@ -78,13 +74,7 @@ public class PacketCollector {
// If the packet collector has already been cancelled, do nothing.
if (!cancelled) {
cancelled = true;
// Remove object from collectors list by setting the value in the
// list at the correct index to null. The collector thread will
// automatically remove the actual list entry when it can.
synchronized (packetReader.collectors) {
int index = packetReader.collectors.indexOf(this);
packetReader.collectors.set(index, null);
}
packetReader.cancelPacketCollector(this);
}
}