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

Listeners are now removed from PacketReader. SMACK-165

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@4883 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Gaston Dombiak 2006-08-10 22:09:30 +00:00 committed by gato
parent 469ff4d487
commit 157a1e9659
2 changed files with 50 additions and 7 deletions

View file

@ -50,7 +50,7 @@ class PacketReader {
private boolean done = false;
private final VolatileMemberCollection<PacketCollector> collectors =
new VolatileMemberCollection<PacketCollector>(50);
private final VolatileMemberCollection listeners = new VolatileMemberCollection(50);
protected final VolatileMemberCollection listeners = new VolatileMemberCollection(50);
protected final List<ConnectionListener> connectionListeners =
new ArrayList<ConnectionListener>();
@ -814,10 +814,13 @@ class PacketReader {
public void remove(E member) {
synchronized (mutex) {
int index = collectors.lastIndexOf(member);
if (index >= 0) {
collectors.set(index, null);
nullArray[++nullIndex] = index;
for (int i = collectors.size()-1; i >= 0; i--) {
E element = collectors.get(i);
if (element != null && element.equals(member)) {
collectors.set(i, null);
nullArray[++nullIndex] = i;
return;
}
}
}
}
@ -860,6 +863,21 @@ class PacketReader {
}
};
}
/**
* Returns the number of elements in this collection.
*
* @return the number of elements in this collection
*/
public int size() {
int size = 0;
for (E element : collectors) {
if (element != null) {
size++;
}
}
return size;
}
}
/**