diff options
author | Mark Spruiell <mes@zeroc.com> | 2015-03-11 13:00:43 -0700 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2015-03-11 13:00:43 -0700 |
commit | 5166c1c2ec79223221fbfcadf1f8ef5e7bb9bae9 (patch) | |
tree | c919eb10cefb7b31ca0030405632c3100fa7ec68 /java/src | |
parent | Fixed OutputUtil to not use char* in the API (diff) | |
download | ice-5166c1c2ec79223221fbfcadf1f8ef5e7bb9bae9.tar.bz2 ice-5166c1c2ec79223221fbfcadf1f8ef5e7bb9bae9.tar.xz ice-5166c1c2ec79223221fbfcadf1f8ef5e7bb9bae9.zip |
ICE-6232 - UI demos should use dispatcher
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/Ice/src/main/java/Ice/ConnectionI.java | 52 | ||||
-rw-r--r-- | java/src/Ice/src/main/java/IceInternal/QueueExecutorService.java | 6 |
2 files changed, 50 insertions, 8 deletions
diff --git a/java/src/Ice/src/main/java/Ice/ConnectionI.java b/java/src/Ice/src/main/java/Ice/ConnectionI.java index 3a028d88c72..7ceeb9ee495 100644 --- a/java/src/Ice/src/main/java/Ice/ConnectionI.java +++ b/java/src/Ice/src/main/java/Ice/ConnectionI.java @@ -9,6 +9,8 @@ package Ice; +import java.util.concurrent.Callable; + public final class ConnectionI extends IceInternal.EventHandler implements Connection, IceInternal.ResponseHandler, IceInternal.CancellationHandler { @@ -1154,6 +1156,8 @@ public final class ConnectionI extends IceInternal.EventHandler // if(dispatchedCount > 0) { + boolean queueShutdown = false; + synchronized(this) { _dispatchCount -= dispatchedCount; @@ -1167,22 +1171,60 @@ public final class ConnectionI extends IceInternal.EventHandler // if(_state == StateClosing) { - try + if(_instance.queueRequests()) { - initiateShutdown(); + // + // We can't call initiateShutdown() from this thread in certain + // situations (such as in Android). + // + queueShutdown = true; } - catch(Ice.LocalException ex) + else { - setState(StateClosed, ex); + try + { + initiateShutdown(); + } + catch(Ice.LocalException ex) + { + setState(StateClosed, ex); + } } } else if(_state == StateFinished) { reap(); } - notifyAll(); + if(!queueShutdown) + { + notifyAll(); + } } } + + if(queueShutdown) + { + _instance.getQueueExecutor().executeNoThrow(new Callable<Void>() + { + @Override + public Void call() throws Exception + { + synchronized(ConnectionI.this) + { + try + { + initiateShutdown(); + } + catch(Ice.LocalException ex) + { + setState(StateClosed, ex); + } + ConnectionI.this.notifyAll(); + } + return null; + } + }); + } } } diff --git a/java/src/Ice/src/main/java/IceInternal/QueueExecutorService.java b/java/src/Ice/src/main/java/IceInternal/QueueExecutorService.java index 1e493bcaefc..1b954923d53 100644 --- a/java/src/Ice/src/main/java/IceInternal/QueueExecutorService.java +++ b/java/src/Ice/src/main/java/IceInternal/QueueExecutorService.java @@ -15,7 +15,7 @@ import java.util.concurrent.Future; import java.util.concurrent.ExecutionException; import java.util.concurrent.RejectedExecutionException; -final class QueueExecutorService +public final class QueueExecutorService { QueueExecutorService(ExecutorService executor) { @@ -30,7 +30,7 @@ final class QueueExecutorService }); } - <T> T executeNoThrow(Callable<T> callable) + public <T> T executeNoThrow(Callable<T> callable) { try { @@ -43,7 +43,7 @@ final class QueueExecutorService } } - <T> T execute(Callable<T> callable) + public <T> T execute(Callable<T> callable) throws RetryException { if(_thread == Thread.currentThread()) |