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,7 @@ void createProposalSelector() {
341
345
void cancelFutures () {
342
346
toCancelFutures .forEach (future -> future .cancel (true ));
343
347
toCancelFutures .clear ();
348
+ completionFuturesExecutor .shutdownNow ();
344
349
}
345
350
346
351
@ Override
@@ -371,6 +376,8 @@ protected List<CompletableFuture<List<ICompletionProposal>>> buildCompletionFutu
371
376
return Collections .emptyList ();
372
377
}
373
378
List <CompletableFuture <List <ICompletionProposal >>> futures = new ArrayList <>(processors .size ());
379
+ completionFuturesExecutor = Executors .newSingleThreadExecutor ();
380
+
374
381
for (IContentAssistProcessor processor : processors ) {
375
382
futures .add (CompletableFuture .supplyAsync (() -> {
376
383
AtomicReference <List <ICompletionProposal >> result = new AtomicReference <>();
@@ -389,7 +396,7 @@ protected List<CompletableFuture<List<ICompletionProposal>>> buildCompletionFutu
389
396
return Collections .emptyList ();
390
397
}
391
398
return proposals ;
392
- }));
399
+ }, completionFuturesExecutor ));
393
400
}
394
401
return futures ;
395
402
}
0 commit comments