From f1095376429064e155b8e90dfbeb2562dec622b4 Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Fri, 5 Jul 2013 15:42:58 +0200 Subject: [PATCH] filecontentloading thread waits for participating indexing threads to finish --- .../src/com/intellij/openapi/project/FileContentQueue.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/project/FileContentQueue.java b/platform/platform-impl/src/com/intellij/openapi/project/FileContentQueue.java index 1fdfd021d59f..5f93a03eb6c0 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/FileContentQueue.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/FileContentQueue.java @@ -69,6 +69,9 @@ public class FileContentQueue { file = myFilesToLoadQueue.poll(); } + synchronized (myProceedWithProcessingLock) { + while (myBytesBeingProcessed > 0) myProceedWithProcessingLock.wait(); + } // put end-of-queue marker only if not canceled try { myLoadedContentsQueue.put(new FileContent(null)); @@ -248,7 +251,7 @@ public class FileContentQueue { synchronized (myProceedWithLoadingLock) { myLoadedBytesInQueue -= result.getLength(); - myProceedWithLoadingLock.notify(); // we ask only content loading thread to proceed, TODO: fix if more than one loading thread + myProceedWithLoadingLock.notifyAll(); // we actually ask only content loading thread to proceed, so there should not be much difference with plain notify } return result;