IJPL-149317 Disable Write Intent Lock for runnables executed on EDT

Add explicit locks in Execution manager.

GitOrigin-RevId: cc395e2e621ffe73d2c36bd91b8c5f84368b45cd
This commit is contained in:
Lev Serebryakov
2024-08-09 15:36:58 +02:00
committed by intellij-monorepo-bot
parent df7dbf79f4
commit 550bce8bb2

View File

@@ -591,36 +591,39 @@ open class ExecutionManagerImpl(private val project: Project, coroutineScope: Co
awaitingRunProfiles[environment.runProfile] = environment
// Can be called via Alarm, which doesn't provide implicit WIRA
awaitTermination(object : Runnable {
override fun run() {
if (awaitingRunProfiles[environment.runProfile] !== environment) {
// a new rerun has been requested before starting this one, ignore this rerun
return
}
val inProgressEntry = InProgressEntry(configuration?.uniqueID ?: "", environment.executor.id, environment.runner.runnerId)
if ((configuration != null && !configuration.type.isDumbAware && DumbService.getInstance(project).isDumb)
|| inProgress.contains(inProgressEntry)) {
awaitTermination(this, 100)
return
}
for (descriptor in runningOfTheSameType) {
val processHandler = descriptor.processHandler
if (processHandler != null && !processHandler.isProcessTerminated) {
awaitTermination(this, 100)
return
WriteIntentReadAction.run wira@{
if (awaitingRunProfiles[environment.runProfile] !== environment) {
// a new rerun has been requested before starting this one, ignore this rerun
return@wira
}
val inProgressEntry = InProgressEntry(configuration?.uniqueID ?: "", environment.executor.id, environment.runner.runnerId)
if ((configuration != null && !configuration.type.isDumbAware && DumbService.getInstance(project).isDumb)
|| inProgress.contains(inProgressEntry)) {
awaitTermination(this, 100)
return@wira
}
for (descriptor in runningOfTheSameType) {
val processHandler = descriptor.processHandler
if (processHandler != null && !processHandler.isProcessTerminated) {
awaitTermination(this, 100)
return@wira
}
}
awaitingRunProfiles.remove(environment.runProfile)
// start() can be called during restartRunProfile() after pretty long 'awaitTermination()' so we have to check if the project is still here
if (environment.project.isDisposed) {
return@wira
}
val settings = environment.runnerAndConfigurationSettings
executeConfiguration(environment, settings != null && settings.isEditBeforeRun)
}
awaitingRunProfiles.remove(environment.runProfile)
// start() can be called during restartRunProfile() after pretty long 'awaitTermination()' so we have to check if the project is still here
if (environment.project.isDisposed) {
return
}
val settings = environment.runnerAndConfigurationSettings
executeConfiguration(environment, settings != null && settings.isEditBeforeRun)
}
}, 50)
}