From a44ae07bf9a8d6d56f43a940995a0b4bea08673f Mon Sep 17 00:00:00 2001 From: Julia Beliaeva Date: Wed, 18 Mar 2015 19:52:01 +0300 Subject: [PATCH] [vcs-log] remove volatiles and ensure that everything is called from EDT; also inline underused method --- .../vcs/log/data/ContainingBranchesGetter.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/ContainingBranchesGetter.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/ContainingBranchesGetter.java index 594dce3b49ec..28568e48c41d 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/ContainingBranchesGetter.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/ContainingBranchesGetter.java @@ -44,12 +44,14 @@ public class ContainingBranchesGetter implements VcsLogListener { @NotNull private final SequentialLimitedLifoExecutor myTaskExecutor; @NotNull private final VcsLogDataHolder myDataHolder; - @NotNull private volatile SLRUMap> myCache = createCache(); - @Nullable private Runnable myLoadingFinishedListener; // access only from EDT + + // other fields accessed only from EDT + @NotNull private SLRUMap> myCache = createCache(); + @NotNull private Map myConditions = ContainerUtil.newHashMap(); + @Nullable private Runnable myLoadingFinishedListener; private int myCurrentBranchesChecksum; @Nullable private VcsLogRefs myRefs; @Nullable private PermanentGraph myGraph; - @NotNull private volatile Map myConditions = ContainerUtil.newHashMap(); ContainingBranchesGetter(@NotNull VcsLogDataHolder dataHolder, @NotNull Disposable parentDisposable) { myDataHolder = dataHolder; @@ -72,6 +74,7 @@ public class ContainingBranchesGetter implements VcsLogListener { @Override public void onChange(@NotNull VcsLogDataPack dataPack, boolean refreshHappened) { + LOG.assertTrue(EventQueue.isDispatchThread()); if (refreshHappened) { myRefs = dataPack.getRefs(); Collection currentBranches = myRefs.getBranches(); @@ -122,20 +125,17 @@ public class ContainingBranchesGetter implements VcsLogListener { */ @Nullable public List requestContainingBranches(@NotNull VirtualFile root, @NotNull Hash hash) { - List refs = getContainingBranchesIfAvailable(hash); + LOG.assertTrue(EventQueue.isDispatchThread()); + List refs = myCache.get(hash); if (refs == null) { myTaskExecutor.queue(new Task(root, hash, myCache, myGraph, myRefs)); } return refs; } - @Nullable - public List getContainingBranchesIfAvailable(@NotNull Hash hash) { - return myCache.get(hash); - } - @NotNull public Condition getContainedInBranchCondition(@NotNull final String branchName, @NotNull final VirtualFile root) { + LOG.assertTrue(EventQueue.isDispatchThread()); if (myRefs == null || myGraph == null) return Conditions.alwaysFalse(); VcsRef branchRef = ContainerUtil.find(myRefs.getBranches(), new Condition() { @Override