Skip to content

Use a separate ExecutorService in AsyncCompletionProposalPopup #3157

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -70,6 +72,8 @@ class AsyncCompletionProposalPopup extends CompletionProposalPopup {

private PopupVisibleTimer fPopupVisibleTimer= new PopupVisibleTimer();

private ExecutorService completionFuturesExecutor;

private static final class ComputingProposal implements ICompletionProposal, ICompletionProposalExtension {

private final int fOffset;
Expand Down Expand Up @@ -341,6 +345,9 @@ void createProposalSelector() {
void cancelFutures() {
toCancelFutures.forEach(future -> future.cancel(true));
toCancelFutures.clear();
if (completionFuturesExecutor != null) {
completionFuturesExecutor.shutdownNow();
}
}

@Override
Expand Down Expand Up @@ -371,6 +378,8 @@ protected List<CompletableFuture<List<ICompletionProposal>>> buildCompletionFutu
return Collections.emptyList();
}
List<CompletableFuture<List<ICompletionProposal>>> futures = new ArrayList<>(processors.size());
completionFuturesExecutor= Executors.newSingleThreadExecutor();

for (IContentAssistProcessor processor : processors) {
futures.add(CompletableFuture.supplyAsync(() -> {
AtomicReference<List<ICompletionProposal>> result= new AtomicReference<>();
Expand All @@ -389,7 +398,7 @@ protected List<CompletableFuture<List<ICompletionProposal>>> buildCompletionFutu
return Collections.emptyList();
}
return proposals;
}));
}, completionFuturesExecutor));
}
return futures;
}
Expand Down
Loading