- synchronized the reset() method
- avoid synchronization in waitForResponse() if possible. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1684 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -73,7 +73,7 @@ public class ServiceWaiter
|
|||||||
/**
|
/**
|
||||||
* Reset the service waiter so that it can be used again.
|
* Reset the service waiter so that it can be used again.
|
||||||
*/
|
*/
|
||||||
public void reset ()
|
public synchronized void reset ()
|
||||||
{
|
{
|
||||||
_success = 0;
|
_success = 0;
|
||||||
_argument = null;
|
_argument = null;
|
||||||
@@ -116,9 +116,11 @@ public class ServiceWaiter
|
|||||||
* @return true if a success response was posted, false if a failure
|
* @return true if a success response was posted, false if a failure
|
||||||
* repsonse was posted.
|
* repsonse was posted.
|
||||||
*/
|
*/
|
||||||
public synchronized boolean waitForResponse ()
|
public boolean waitForResponse ()
|
||||||
throws TimeoutException
|
throws TimeoutException
|
||||||
{
|
{
|
||||||
|
if (_success == 0) {
|
||||||
|
synchronized (this) {
|
||||||
while (_success == 0) {
|
while (_success == 0) {
|
||||||
try {
|
try {
|
||||||
// wait for the response, timing out after a while
|
// wait for the response, timing out after a while
|
||||||
@@ -139,6 +141,8 @@ public class ServiceWaiter
|
|||||||
// fall through and wait again
|
// fall through and wait again
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (_success > 0);
|
return (_success > 0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user