DataflowResult (PsiExpression context) { PsiElement body = DfaUtil.getDataflowContext(context); if (body == null) return null; ConcurrentHashMap<PsiElement, DataflowResult> fileMap = CachedValuesManager.getCachedValue(body.getContainingFile(), () -> CachedValueProvider.Result.create(new ConcurrentHashMap<>(), PsiModificationTracker.MODIFICATION_COUNT)); class ManagedCompute implements ForkJoinPool.ManagedBlocker { DataflowResult myResult; @Override public boolean block() { myResult = fileMap.computeIfAbsent(body, CommonDataflow::runDFA); return true; } @Override public boolean isReleasable() { myResult = fileMap.get(body); return myResult != null; } DataflowResult getResult() { return myResult == null || myResult.myResult != RunnerResult.OK ? null : myResult; } } ManagedCompute managedCompute = new ManagedCompute(); try { ForkJoinPool.managedBlock(managedCompute); } catch (RejectedExecutionException ex) { // Too many FJP threads: execute anyway in current thread managedCompute.block(); } catch (InterruptedException ex) { // Should not happen throw new AssertionError(ex); } return managedCompute.getResult(); }