1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 17:26:01 +02:00

Code cleanup.

This commit is contained in:
Sergey Prigogin 2010-03-22 05:33:59 +00:00
parent a06882508c
commit 03cbd47472

View file

@ -70,9 +70,6 @@ import org.eclipse.osgi.util.NLS;
* @since 4.0
*/
abstract public class PDOMWriter {
// TODO(sprigogin): Remove SEMI_TRANSACTIONAL_UPDATES and ALLOW_LOCK_YIELDING constants and simplify the code.
public static boolean SEMI_TRANSACTIONAL_UPDATES = true;
public static boolean ALLOW_LOCK_YIELDING = true;
public static int SKIP_ALL_REFERENCES= -1;
public static int SKIP_TYPE_REFERENCES= 1;
public static int SKIP_MACRO_REFERENCES= 2;
@ -140,8 +137,8 @@ abstract public class PDOMWriter {
/**
* Extracts symbols from the given AST and adds them to the index.
*
* When flushIndex is set to <code>false</code>, you must make sure to flush the
* index after your last write operation.
* When flushIndex is set to <code>false</code>, you must make sure to flush
* the index after your last write operation.
* @since 4.0
*/
public void addSymbols(IASTTranslationUnit ast, IIndexFileLocation[] ifls, IWritableIndex index,
@ -465,11 +462,10 @@ abstract public class PDOMWriter {
Set<IIndexFileLocation> clearedContexts= Collections.emptySet();
IIndexFragmentFile file;
long timestamp = fResolver.getLastModified(location);
if (SEMI_TRANSACTIONAL_UPDATES) {
// In fine grained locking mode we create a temporary PDOMFile with zero timestamp,
// add names to it, then replace contents of the old file from the temporary one, then
// delete the temporary file. The write lock on the index is periodically yielded while
// adding names to the temporary file, if the process takes long time.
// We create a temporary PDOMFile with zero timestamp, add names to it, then replace contents
// of the old file from the temporary one, then delete the temporary file. The write lock on
// the index can be yielded between adding names to the temporary file, if another thread
// is waiting for a read lock.
IIndexFragmentFile oldFile = index.getWritableFile(linkageID, location);
if (oldFile != null) {
IIndexInclude[] includedBy = index.findIncludedBy(oldFile);
@ -481,16 +477,6 @@ abstract public class PDOMWriter {
}
}
file= index.addUncommittedFile(linkageID, location);
} else {
file= index.getWritableFile(linkageID, location);
if (file != null) {
clearedContexts= new HashSet<IIndexFileLocation>();
index.clearFile(file, clearedContexts);
} else {
file= index.addFile(linkageID, location);
}
file.setTimestamp(timestamp);
}
try {
file.setScannerConfigurationHashcode(configHash);
Symbols lists= symbolMap.get(location);
@ -515,14 +501,11 @@ abstract public class PDOMWriter {
(contextIncludes.contains(include) || clearedContexts.contains(info.fLocation));
}
}
index.setFileContent(file, linkageID, includeInfos, macros, names, fResolver,
SEMI_TRANSACTIONAL_UPDATES && ALLOW_LOCK_YIELDING ? lock : null);
index.setFileContent(file, linkageID, includeInfos, macros, names, fResolver, lock);
}
if (SEMI_TRANSACTIONAL_UPDATES) {
file.setTimestamp(timestamp);
file.setContentsHash(fileContentsHash);
file = index.commitUncommittedFile();
}
} finally {
index.clearUncommittedFile();
}