diff options
author | Benoit Foucher <benoit@zeroc.com> | 2007-12-12 18:54:19 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2007-12-12 18:54:19 +0100 |
commit | 3dff2b82d498d2e29dc4c42c4053557e16a373d4 (patch) | |
tree | 4242da8678ce8f36e34b9d821212cf78519af415 /java/src/IceInternal/ThreadPool.java | |
parent | Merge branch 'master' of ssh://cvs.zeroc.com/home/git/ice (diff) | |
download | ice-3dff2b82d498d2e29dc4c42c4053557e16a373d4.tar.bz2 ice-3dff2b82d498d2e29dc4c42c4053557e16a373d4.tar.xz ice-3dff2b82d498d2e29dc4c42c4053557e16a373d4.zip |
Fixed bug 2592
Diffstat (limited to 'java/src/IceInternal/ThreadPool.java')
-rw-r--r-- | java/src/IceInternal/ThreadPool.java | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/java/src/IceInternal/ThreadPool.java b/java/src/IceInternal/ThreadPool.java index 6306ca10475..2ba09235fec 100644 --- a/java/src/IceInternal/ThreadPool.java +++ b/java/src/IceInternal/ThreadPool.java @@ -145,7 +145,6 @@ public final class ThreadPool assert(!_destroyed); assert(_handlerMap.isEmpty()); - assert(_changes.isEmpty()); assert(_workItems.isEmpty()); _destroyed = true; setInterrupt(); @@ -197,7 +196,10 @@ public final class ThreadPool public synchronized void execute(ThreadPoolWorkItem workItem) { - assert(!_destroyed); + if(_destroyed) + { + throw new Ice.CommunicatorDestroyedException(); + } _workItems.add(workItem); setInterrupt(); } @@ -529,9 +531,21 @@ public final class ThreadPool // 3. A work item has been scheduled. // - // Thread pool destroyed? - // - if(_destroyed) + if(!_workItems.isEmpty()) + { + // + // Work items must be executed first even if the thread pool is destroyed. + // + + // + // Remove the interrupt channel from the selected key set. + // + _keys.remove(_fdIntrReadKey); + clearInterrupt(); + assert(!_workItems.isEmpty()); + workItem = (ThreadPoolWorkItem)_workItems.removeFirst(); + } + else if(_destroyed) { if(TRACE_SHUTDOWN) { @@ -539,27 +553,22 @@ public final class ThreadPool } // - // Don't clear the interrupt fd if - // destroyed, so that the other threads - // exit as well. + // Don't clear the interrupt fd if destroyed, so that the other threads exit as well. // return true; } - - // - // Remove the interrupt channel from the - // selected key set. - // - _keys.remove(_fdIntrReadKey); - - clearInterrupt(); - - // - // An event handler must have been registered - // or unregistered. - // - if(!_changes.isEmpty()) + else { + // + // Remove the interrupt channel from the selected key set. + // + _keys.remove(_fdIntrReadKey); + clearInterrupt(); + + // + // An event handler must have been registered or unregistered. + // + assert(!_changes.isEmpty()); FdHandlerPair change = (FdHandlerPair)_changes.removeFirst(); if(change.handler != null) // Addition if handler is set. @@ -627,11 +636,6 @@ public final class ThreadPool // outside the thread synchronization. } } - else - { - assert(!_workItems.isEmpty()); - workItem = (ThreadPoolWorkItem)_workItems.removeFirst(); - } } else { |