From ab5b237d74baadca774fcfd4a9cfc909580cf230 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Sun, 25 Oct 2009 06:01:55 +0000 Subject: [PATCH] More granular index locking. Bug 287907. --- .../cdt/internal/core/pdom/PDOMWriter.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMWriter.java index a3c14c9626e..c7f1d61dd34 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMWriter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMWriter.java @@ -191,18 +191,18 @@ abstract public class PDOMWriter { int linkageID, int configHash, HashSet contextIncludes, IWritableIndex index, int readlockCount, boolean flushIndex, ArrayList stati, IProgressMonitor pm) throws InterruptedException, CoreException { - index.acquireWriteLock(readlockCount); - long start= System.currentTimeMillis(); - try { - for (int i= 0; i < ifls.length; i++) { - if (pm.isCanceled()) - return; + for (int i= 0; i < ifls.length; i++) { + if (pm.isCanceled()) + return; - final IIndexFileLocation ifl= ifls[i]; - if (ifl != null) { - if (fShowActivity) { - System.out.println("Indexer: adding " + ifl.getURI()); //$NON-NLS-1$ - } + final IIndexFileLocation ifl= ifls[i]; + if (ifl != null) { + if (fShowActivity) { + System.out.println("Indexer: adding " + ifl.getURI()); //$NON-NLS-1$ + } + index.acquireWriteLock(readlockCount); + long start= System.currentTimeMillis(); + try { Throwable th= null; try { storeFileInIndex(index, ifl, symbolMap, linkageID, configHash, contextIncludes); @@ -220,12 +220,12 @@ abstract public class PDOMWriter { if (i < ifls.length - 1) { updateFileCount(0, 0, 1); // update header count } + } finally { + index.releaseWriteLock(readlockCount, flushIndex); } + fStatistics.fAddToIndexTime+= System.currentTimeMillis() - start; } - } finally { - index.releaseWriteLock(readlockCount, flushIndex); } - fStatistics.fAddToIndexTime+= System.currentTimeMillis()-start; } private void resolveNames(final Map symbolMap, IIndexFileLocation[] ifls,