Author: trustin
Date: Thu Nov 15 20:45:36 2007
New Revision: 595549
URL: http://svn.apache.org/viewvc?rev=595549&view=rev
Log:
Made sure cleanup operation is performed even if IoEvent.run() throws an
exception (which is unlikely though)
Modified:
mina/trunk/core/src/main/java/org/apache/mina/filter/executor/OrderedThreadPoolExecutor.java
mina/trunk/core/src/main/java/org/apache/mina/filter/executor/UnorderedThreadPoolExecutor.java
Modified:
mina/trunk/core/src/main/java/org/apache/mina/filter/executor/OrderedThreadPoolExecutor.java
URL:
http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/filter/executor/OrderedThreadPoolExecutor.java?rev=595549&r1=595548&r2=595549&view=diff
==============================================================================
---
mina/trunk/core/src/main/java/org/apache/mina/filter/executor/OrderedThreadPoolExecutor.java
(original)
+++
mina/trunk/core/src/main/java/org/apache/mina/filter/executor/OrderedThreadPoolExecutor.java
Thu Nov 15 20:45:36 2007
@@ -467,37 +467,39 @@
public void run() {
thread = Thread.currentThread();
-
- for (;;) {
- IoSession session = fetchSession();
-
- idleWorkers.decrementAndGet();
-
- if (session == null) {
- synchronized (workers) {
- if (workers.size() > corePoolSize) {
- // Remove now to prevent duplicate exit.
- workers.remove(this);
- break;
+
+ try {
+ for (;;) {
+ IoSession session = fetchSession();
+
+ idleWorkers.decrementAndGet();
+
+ if (session == null) {
+ synchronized (workers) {
+ if (workers.size() > corePoolSize) {
+ // Remove now to prevent duplicate exit.
+ workers.remove(this);
+ break;
+ }
}
}
+
+ if (session == EXIT_SIGNAL) {
+ break;
+ }
+
+ try {
+ runTasks(getSessionBuffer(session));
+ } finally {
+ idleWorkers.incrementAndGet();
+ }
}
-
- if (session == EXIT_SIGNAL) {
- break;
- }
-
- try {
- runTasks(getSessionBuffer(session));
- } finally {
- idleWorkers.incrementAndGet();
+ } finally {
+ synchronized (workers) {
+ workers.remove(this);
+ OrderedThreadPoolExecutor.this.completedTaskCount +=
completedTaskCount;
+ workers.notifyAll();
}
- }
-
- synchronized (workers) {
- workers.remove(this);
- OrderedThreadPoolExecutor.this.completedTaskCount +=
completedTaskCount;
- workers.notifyAll();
}
}
Modified:
mina/trunk/core/src/main/java/org/apache/mina/filter/executor/UnorderedThreadPoolExecutor.java
URL:
http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/filter/executor/UnorderedThreadPoolExecutor.java?rev=595549&r1=595548&r2=595549&view=diff
==============================================================================
---
mina/trunk/core/src/main/java/org/apache/mina/filter/executor/UnorderedThreadPoolExecutor.java
(original)
+++
mina/trunk/core/src/main/java/org/apache/mina/filter/executor/UnorderedThreadPoolExecutor.java
Thu Nov 15 20:45:36 2007
@@ -410,37 +410,39 @@
public void run() {
thread = Thread.currentThread();
- for (;;) {
- Runnable task = fetchTask();
-
- idleWorkers.decrementAndGet();
-
- if (task == null) {
- synchronized (workers) {
- if (workers.size() > corePoolSize) {
- // Remove now to prevent duplicate exit.
- workers.remove(this);
- break;
+ try {
+ for (;;) {
+ Runnable task = fetchTask();
+
+ idleWorkers.decrementAndGet();
+
+ if (task == null) {
+ synchronized (workers) {
+ if (workers.size() > corePoolSize) {
+ // Remove now to prevent duplicate exit.
+ workers.remove(this);
+ break;
+ }
}
}
+
+ if (task == EXIT_SIGNAL) {
+ break;
+ }
+
+ queueHandler.polled(UnorderedThreadPoolExecutor.this,
(IoEvent) task);
+ try {
+ runTask(task);
+ } finally {
+ idleWorkers.incrementAndGet();
+ }
}
-
- if (task == EXIT_SIGNAL) {
- break;
- }
-
- queueHandler.polled(UnorderedThreadPoolExecutor.this,
(IoEvent) task);
- try {
- runTask(task);
- } finally {
- idleWorkers.incrementAndGet();
+ } finally {
+ synchronized (workers) {
+ workers.remove(this);
+ UnorderedThreadPoolExecutor.this.completedTaskCount +=
completedTaskCount;
+ workers.notifyAll();
}
- }
-
- synchronized (workers) {
- workers.remove(this);
- UnorderedThreadPoolExecutor.this.completedTaskCount +=
completedTaskCount;
- workers.notifyAll();
}
}