@NotNull
 private static String toVfString(@NotNull Collection<VirtualFile> list) {
   List<VirtualFile> sub = new ArrayList<VirtualFile>(list).subList(0, Math.min(list.size(), 100));
   return list.size()
       + " files: "
       + StringUtil.join(sub, file -> file.getName(), ", ")
       + (list.size() == sub.size() ? "" : "...");
 }
  private boolean processFilesConcurrently(
      @NotNull Set<VirtualFile> files,
      @NotNull final ProgressIndicator indicator,
      @NotNull final Processor<VirtualFile> processor) {
    final List<VirtualFile> fileList = new ArrayList<VirtualFile>(files);
    // fine but grabs all CPUs
    // return JobLauncher.getInstance().invokeConcurrentlyUnderProgress(fileList, indicator, false,
    // false, processor);

    int parallelism = CacheUpdateRunner.indexingThreadCount();
    final Callable<Boolean> processFileFromSet =
        () -> {
          final boolean[] result = {true};
          ProgressManager.getInstance()
              .executeProcessUnderProgress(
                  () -> {
                    while (true) {
                      ProgressManager.checkCanceled();
                      VirtualFile file;
                      synchronized (fileList) {
                        file = fileList.isEmpty() ? null : fileList.remove(fileList.size() - 1);
                      }
                      if (file == null) {
                        break;
                      }
                      if (!processor.process(file)) {
                        result[0] = false;
                        break;
                      }
                    }
                  },
                  indicator);
          return result[0];
        };
    List<Future<Boolean>> futures =
        ContainerUtil.map(
            Collections.nCopies(parallelism, ""),
            s -> myApplication.executeOnPooledThread(processFileFromSet));

    List<Boolean> results =
        ContainerUtil.map(
            futures,
            future -> {
              try {
                return future.get();
              } catch (Exception e) {
                LOG.error(e);
              }
              return false;
            });

    return !ContainerUtil.exists(
        results,
        result -> {
          return result != null && !result; // null means PCE
        });
  }
 @NotNull
 private static List<VirtualFile> toVf(@NotNull int[] ids) {
   List<VirtualFile> res = new ArrayList<VirtualFile>();
   for (int id : ids) {
     VirtualFile file = PersistentFS.getInstance().findFileById(id);
     if (file != null) {
       res.add(file);
     }
   }
   return res;
 }
 @Override
 public boolean queue(@NotNull Collection<VirtualFile> files, @NotNull Object reason) {
   if (files.isEmpty()) {
     return false;
   }
   boolean queued = false;
   List<VirtualFile> added = new ArrayList<VirtualFile>(files.size());
   for (VirtualFile file : files) {
     boolean wasAdded = queueIfNeeded(file, myProject);
     if (wasAdded) {
       added.add(file);
     }
     queued |= wasAdded;
   }
   if (queued) {
     log("Queued to resolve (from " + reason + "): " + toVfString(added));
     flushLog();
   }
   return queued;
 }
 @Override
 public void addListener(@NotNull Disposable parent, @NotNull final Listener listener) {
   myListeners.add(listener);
   Disposer.register(
       parent,
       new Disposable() {
         @Override
         public void dispose() {
           myListeners.remove(listener);
         }
       });
 }