From 492517cef2dfdf311705cd2666b11763e1b4510d Mon Sep 17 00:00:00 2001 From: Alexandr Evstigneev Date: Sat, 17 Aug 2024 14:22:55 +0400 Subject: [PATCH 1/2] Better synchronization for mojo model update On previous solution code flow could squeeze between conditions of queue and running update, but now we are done only after we done. Fixup for b6c80a294990111408e8efcce2c7a678f84cae7f --- .../mojolicious/model/MojoProjectManager.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/mojo/core/src/main/java/com/perl5/lang/mojolicious/model/MojoProjectManager.java b/mojo/core/src/main/java/com/perl5/lang/mojolicious/model/MojoProjectManager.java index c828c621ec..674744f5d4 100644 --- a/mojo/core/src/main/java/com/perl5/lang/mojolicious/model/MojoProjectManager.java +++ b/mojo/core/src/main/java/com/perl5/lang/mojolicious/model/MojoProjectManager.java @@ -45,6 +45,7 @@ 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; @@ -56,6 +57,7 @@ public class MojoProjectManager implements Disposable { private final @NotNull MergingUpdateQueue myUpdateQueue; private final @NotNull AtomicBoolean myUpdatingModel = new AtomicBoolean(false); private volatile @NotNull Model myModel = new Model(Collections.emptySet()); + private volatile Semaphore myTestSemaphore; public MojoProjectManager(@NotNull Project project) { myProject = project; @@ -140,7 +142,16 @@ private void updateModel() { scheduleUpdate(); } else { - doUpdateModel(); + try{ + LOG.debug("Performing model update"); + doUpdateModel(); + } + finally { + if( myTestSemaphore != null) { + myTestSemaphore.up(); + myTestSemaphore = null; + } + } } }); } @@ -281,7 +292,9 @@ private Set getProjects() { @TestOnly public BooleanSupplier updateInTestMode() { + var semaphore = new Semaphore(1); + myTestSemaphore = semaphore; updateModel(); - return ()-> myUpdateQueue.isEmpty() && !myUpdatingModel.get(); + return semaphore::isUp; } } From 14233b0b668e8fd0853124853a5c35b624923308 Mon Sep 17 00:00:00 2001 From: Alexandr Evstigneev Date: Sat, 17 Aug 2024 14:23:20 +0400 Subject: [PATCH 2/2] Added docker test configuration --- .../Test_Plugin__Docker_.xml | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .idea/runConfigurations/Test_Plugin__Docker_.xml diff --git a/.idea/runConfigurations/Test_Plugin__Docker_.xml b/.idea/runConfigurations/Test_Plugin__Docker_.xml new file mode 100644 index 0000000000..4697178688 --- /dev/null +++ b/.idea/runConfigurations/Test_Plugin__Docker_.xml @@ -0,0 +1,29 @@ + + + + + + + + true + true + false + true + + + \ No newline at end of file