diff options
Diffstat (limited to 'java/src/IceInternal/ThreadPool.java')
-rw-r--r-- | java/src/IceInternal/ThreadPool.java | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/java/src/IceInternal/ThreadPool.java b/java/src/IceInternal/ThreadPool.java index 8ab584e9623..8d350b1e19c 100644 --- a/java/src/IceInternal/ThreadPool.java +++ b/java/src/IceInternal/ThreadPool.java @@ -82,6 +82,7 @@ public final class ThreadPool ThreadPool(Instance instance, String prefix, int timeout) { _instance = instance; + _dispatcher = instance.initializationData().dispatcher; _destroyed = false; _prefix = prefix; _selector = new Selector(instance); @@ -278,7 +279,6 @@ public final class ThreadPool { return; } - _selector.update(handler, remove, add); if((add & SocketOperation.Read) != 0 && handler._hasMoreData.value && @@ -311,7 +311,34 @@ public final class ThreadPool } public void - execute(ThreadPoolWorkItem workItem) + dispatchFromThisThread(DispatchWorkItem workItem) + { + if(_dispatcher != null) + { + try + { + _dispatcher.dispatch(workItem, workItem.getConnection()); + } + catch(java.lang.Exception ex) + { + if(_instance.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 1) + { + java.io.StringWriter sw = new java.io.StringWriter(); + java.io.PrintWriter pw = new java.io.PrintWriter(sw); + ex.printStackTrace(pw); + pw.flush(); + _instance.initializationData().logger.warning("dispatch exception:\n" + sw.toString()); + } + } + } + else + { + workItem.run(); + } + } + + public void + dispatch(DispatchWorkItem workItem) { _workQueue.queue(workItem); } @@ -698,6 +725,7 @@ public final class ThreadPool } private final Instance _instance; + private final Ice.Dispatcher _dispatcher; private final ThreadPoolWorkQueue _workQueue; private boolean _destroyed; private final String _prefix; |