25
25
import java .util .Set ;
26
26
import java .util .concurrent .CompletableFuture ;
27
27
import java .util .concurrent .ExecutionException ;
28
+ import java .util .concurrent .ExecutorService ;
29
+ import java .util .concurrent .Executors ;
28
30
import java .util .concurrent .TimeUnit ;
29
31
import java .util .concurrent .TimeoutException ;
30
32
import java .util .concurrent .atomic .AtomicInteger ;
@@ -70,6 +72,8 @@ class AsyncCompletionProposalPopup extends CompletionProposalPopup {
70
72
71
73
private PopupVisibleTimer fPopupVisibleTimer = new PopupVisibleTimer ();
72
74
75
+ private ExecutorService completionFuturesExecutor ;
76
+
73
77
private static final class ComputingProposal implements ICompletionProposal , ICompletionProposalExtension {
74
78
75
79
private final int fOffset ;
@@ -341,6 +345,9 @@ void createProposalSelector() {
341
345
void cancelFutures () {
342
346
toCancelFutures .forEach (future -> future .cancel (true ));
343
347
toCancelFutures .clear ();
348
+ if (completionFuturesExecutor != null ) {
349
+ completionFuturesExecutor .shutdownNow ();
350
+ }
344
351
}
345
352
346
353
@ Override
@@ -371,6 +378,8 @@ protected List<CompletableFuture<List<ICompletionProposal>>> buildCompletionFutu
371
378
return Collections .emptyList ();
372
379
}
373
380
List <CompletableFuture <List <ICompletionProposal >>> futures = new ArrayList <>(processors .size ());
381
+ completionFuturesExecutor = Executors .newSingleThreadExecutor ();
382
+
374
383
for (IContentAssistProcessor processor : processors ) {
375
384
futures .add (CompletableFuture .supplyAsync (() -> {
376
385
AtomicReference <List <ICompletionProposal >> result = new AtomicReference <>();
@@ -389,7 +398,7 @@ protected List<CompletableFuture<List<ICompletionProposal>>> buildCompletionFutu
389
398
return Collections .emptyList ();
390
399
}
391
400
return proposals ;
392
- }));
401
+ }, completionFuturesExecutor ));
393
402
}
394
403
return futures ;
395
404
}
0 commit comments