Skip to content

Commit

Permalink
Executor service fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pepone committed Dec 26, 2024
1 parent 075234d commit 09a5f99
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 25 deletions.
10 changes: 7 additions & 3 deletions java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/Instance.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,19 @@ protected void afterExecute(Runnable t, Throwable e) {
private final ThreadObserverHelper _observerHelper;
}

// The thead pool executor uses an unbounded queue. The tasks would wait in the queue until a
// core pool thread is available to run it and the value of the maximumPoolSize therefore
// doesn't have any effect.
private static class QueueExecutor extends java.util.concurrent.ThreadPoolExecutor {
QueueExecutor(Properties props, String threadName) {
super(
1,
1,
0,
10,
10,
1000,
TimeUnit.MILLISECONDS,
new java.util.concurrent.LinkedBlockingQueue<Runnable>(),
Util.createThreadFactory(props, threadName));
allowCoreThreadTimeOut(true);
_observerHelper = new ThreadObserverHelper(threadName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@
final class QueueExecutorService {
QueueExecutorService(ExecutorService executor) {
_executor = executor;
_thread =
executeNoThrow(
new Callable<Thread>() {
@Override
public Thread call() {
return Thread.currentThread();
}
});
}

public <T> T executeNoThrow(Callable<T> callable) {
Expand All @@ -33,19 +25,6 @@ public <T> T executeNoThrow(Callable<T> callable) {
}

public <T> T execute(Callable<T> callable) throws RetryException {
if (_thread == Thread.currentThread()) {
try {
return callable.call();
} catch (RuntimeException ex) {
throw ex;
} catch (Exception ex) {
// RetryException is the only checked exception that
// can be raised by Ice internals.
assert (ex instanceof RetryException);
throw (RetryException) ex;
}
}

boolean interrupted = false;
try {
Future<T> future = _executor.submit(callable);
Expand Down Expand Up @@ -78,5 +57,4 @@ public <T> T execute(Callable<T> callable) throws RetryException {
}

final ExecutorService _executor;
final Thread _thread;
}

0 comments on commit 09a5f99

Please sign in to comment.