use of com.intellij.compiler.CompilerManagerImpl in project intellij-community by JetBrains.
the class CompilerTask method run.
@Override
public void run(@NotNull final ProgressIndicator indicator) {
myIndicator = indicator;
final ProjectManager projectManager = ProjectManager.getInstance();
projectManager.addProjectManagerListener(myProject, myCloseListener = new CloseListener());
final Semaphore semaphore = ((CompilerManagerImpl) CompilerManager.getInstance(myProject)).getCompilationSemaphore();
boolean acquired = false;
try {
try {
while (!acquired) {
acquired = semaphore.tryAcquire(300, TimeUnit.MILLISECONDS);
if (!acquired && !myWaitForPreviousSession) {
return;
}
if (indicator.isCanceled()) {
// let compile work begin in order to stop gracefuly on cancel event
break;
}
}
} catch (InterruptedException ignored) {
}
if (!isHeadless()) {
addIndicatorDelegate();
}
myCompileWork.run();
} catch (ProcessCanceledException ignored) {
} finally {
try {
indicator.stop();
projectManager.removeProjectManagerListener(myProject, myCloseListener);
} finally {
if (acquired) {
semaphore.release();
}
}
}
}
Aggregations