1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-12 02:29:38 +02:00

Phase 1 of large refactoring. Removing dead code, bug fixes, updates to JDK 1.5.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@4511 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Matt Tucker 2006-07-17 08:39:08 +00:00 committed by matt
parent 1a08715f67
commit bbbfe09c31
62 changed files with 291 additions and 3524 deletions

View file

@ -135,17 +135,34 @@ public class PacketCollector {
public synchronized Packet nextResult(long timeout) {
// Wait up to the specified amount of time for a result.
if (resultQueue.isEmpty()) {
long waitTime = timeout;
long start = System.currentTimeMillis();
try {
wait(timeout);
// Keep waiting until the specified amount of time has elapsed, or
// a packet is available to return.
while (resultQueue.isEmpty()) {
if (waitTime <= 0) {
break;
}
wait(waitTime);
long now = System.currentTimeMillis();
waitTime -= (now - start);
start = now;
}
}
catch (InterruptedException ie) {
// Ignore.
}
// Still haven't found a result, so return null.
if (resultQueue.isEmpty()) {
return null;
}
// Return the packet that was found.
else {
return (Packet)resultQueue.removeLast();
}
}
// If still no result, return null.
if (resultQueue.isEmpty()) {
return null;
}
// There's already a packet waiting, so return it.
else {
return (Packet)resultQueue.removeLast();
}