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

Closed
wants to merge 1 commit into from
Closed
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is not clear.

Presumably, maximumPoolSize has not effect because the executor uses an unbounded queue? As written, it sounds like a consequence of the wait?

It's also not clear to me what this means / add:

The tasks would wait in the queue until a core pool thread is available to run it

This is not obvious?

private static class QueueExecutor extends java.util.concurrent.ThreadPoolExecutor {
QueueExecutor(Properties props, String threadName) {
super(
1,
1,
0,
10,
10,
1000,
Comment on lines +91 to +93
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do these magic numbers refer to?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so the 1000 for keepAliveTime will have no effect here since we're setting core and max to 10.

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