use of com.intellij.openapi.util.ShutDownTracker in project intellij-community by JetBrains.
the class DumbServiceImpl method runBackgroundProcess.
private void runBackgroundProcess(@NotNull final ProgressIndicator visibleIndicator) {
if (!myState.compareAndSet(State.SCHEDULED_TASKS, State.RUNNING_DUMB_TASKS))
return;
final ShutDownTracker shutdownTracker = ShutDownTracker.getInstance();
final Thread self = Thread.currentThread();
try {
shutdownTracker.registerStopperThread(self);
if (visibleIndicator instanceof ProgressIndicatorEx) {
((ProgressIndicatorEx) visibleIndicator).addStateDelegate(new AppIconProgress());
}
DumbModeTask task = null;
while (true) {
Pair<DumbModeTask, ProgressIndicatorEx> pair = getNextTask(task, visibleIndicator);
if (pair == null)
break;
task = pair.first;
ProgressIndicatorEx taskIndicator = pair.second;
if (visibleIndicator instanceof ProgressIndicatorEx) {
taskIndicator.addStateDelegate(new AbstractProgressIndicatorExBase() {
@Override
protected void delegateProgressChange(@NotNull IndicatorAction action) {
super.delegateProgressChange(action);
action.execute((ProgressIndicatorEx) visibleIndicator);
}
});
}
try (AccessToken ignored = HeavyProcessLatch.INSTANCE.processStarted("Performing indexing tasks")) {
runSingleTask(task, taskIndicator);
}
}
} catch (Throwable unexpected) {
LOG.error(unexpected);
} finally {
shutdownTracker.unregisterStopperThread(self);
}
}
Aggregations