Checking in Ray's update to ServiceWaiter.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@2374 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
andrzej@threerings.net
2008-08-28 23:08:04 +00:00
parent 403200041e
commit add5867c13
+15 -17
View File
@@ -143,25 +143,23 @@ public class ServiceWaiter<T>
{ {
if (_success == 0) { if (_success == 0) {
synchronized (this) { synchronized (this) {
while (_success == 0) { try {
try { // wait for the response, timing out after a while
// wait for the response, timing out after a while if (_timeout == NO_TIMEOUT) {
if (_timeout == NO_TIMEOUT) { wait();
wait();
} else { } else {
wait(1000L * _timeout); wait(1000L * _timeout);
}
// if we get here without some sort of response, then
// we've timed out
if (_success == 0) {
throw new TimeoutException();
}
} catch (InterruptedException ie) {
// fall through and wait again
} }
// if we get here without some sort of response, then
// we've timed out
if (_success == 0) {
throw new TimeoutException();
}
} catch (InterruptedException ie) {
throw (TimeoutException)
new TimeoutException().initCause(ie);
} }
} }
} }