mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[^cdr] fix data race in DumbService.runWhenSmart
This commit is contained in:
@@ -64,7 +64,9 @@ public abstract class DumbService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the runnable immediately if not in dumb mode, or on AWT Event Dispatch thread when the dumb mode ends.
|
||||
* Executes the runnable immediately if not in dumb mode, or on AWT Event Dispatch thread after the dumb mode ends.
|
||||
* Note that it's not guaranteed that the dumb mode won't start again during this runnable execution, it should manage that situation explicitly
|
||||
* (e.g. by starting a read action; it's still necessary to check isDumb inside the read action).
|
||||
* @param runnable runnable to run
|
||||
*/
|
||||
public abstract void runWhenSmart(@NotNull Runnable runnable);
|
||||
|
||||
@@ -151,14 +151,14 @@ public class DumbServiceImpl extends DumbService implements Disposable, Modifica
|
||||
|
||||
@Override
|
||||
public void runWhenSmart(@NotNull Runnable runnable) {
|
||||
if (!isDumb()) {
|
||||
runnable.run();
|
||||
}
|
||||
else {
|
||||
synchronized (myRunWhenSmartQueue) {
|
||||
synchronized (myRunWhenSmartQueue) {
|
||||
if (isDumb()) {
|
||||
myRunWhenSmartQueue.addLast(runnable);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
runnable.run();
|
||||
}
|
||||
|
||||
private void scheduleCacheUpdate(@NotNull final DumbModeTask task, boolean forceDumbMode) {
|
||||
@@ -220,7 +220,9 @@ public class DumbServiceImpl extends DumbService implements Disposable, Modifica
|
||||
application.runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
myDumb = true;
|
||||
synchronized (myRunWhenSmartQueue) {
|
||||
myDumb = true;
|
||||
}
|
||||
myDumbStart = trace;
|
||||
myModificationCount++;
|
||||
try {
|
||||
@@ -286,7 +288,9 @@ public class DumbServiceImpl extends DumbService implements Disposable, Modifica
|
||||
}
|
||||
|
||||
private void updateFinished(boolean modal) {
|
||||
myDumb = false;
|
||||
synchronized (myRunWhenSmartQueue) {
|
||||
myDumb = false;
|
||||
}
|
||||
myDumbStart = null;
|
||||
myModificationCount++;
|
||||
if (myProject.isDisposed()) return;
|
||||
|
||||
Reference in New Issue
Block a user