Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Executor service fixes #3307

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
Loading