Skip to content

Commit

Permalink
Update mojo project structure under non blocking read action
Browse files Browse the repository at this point in the history
  • Loading branch information
hurricup committed Sep 28, 2024
1 parent 850493a commit 9406cb0
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.util.concurrency.Semaphore;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.messages.MessageBusConnection;
import com.intellij.util.ui.update.MergingUpdateQueue;
Expand All @@ -45,7 +46,6 @@
import org.jetbrains.annotations.TestOnly;

import java.util.*;
import com.intellij.util.concurrency.Semaphore;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.BooleanSupplier;

Expand Down Expand Up @@ -132,7 +132,8 @@ private void updateModel() {
LOG.debug("Attempting to update");
if (!myUpdatingModel.getAndSet(true)) {
try {
ReadAction.run(() -> {
//noinspection deprecation
ReadAction.nonBlocking(() -> {
if (myProject.isDisposed()) {
LOG.warn("Project is disposed");
return;
Expand All @@ -142,18 +143,18 @@ private void updateModel() {
scheduleUpdate();
}
else {
try{
try {
LOG.debug("Performing model update");
doUpdateModel();
}
finally {
if( myTestSemaphore != null) {
if (myTestSemaphore != null) {
myTestSemaphore.up();
myTestSemaphore = null;
}
}
}
});
}).executeSynchronously();
}
catch (ProcessCanceledException e) {
LOG.debug("Update was cancelled, rescheduling");
Expand Down

0 comments on commit 9406cb0

Please sign in to comment.