mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-30 04:15:35 +02:00
Patch for Bogdan Gheorghe
This patch adds a layer of separation between the indexer and the parser by running the parser in its own thread. This allows the indexer to finish all jobs regardless of the individual parser outcomes. Also fixed a potential EOF bug while reading stored indexes.
This commit is contained in:
parent
da13b999cd
commit
a69ae2ccf2
3 changed files with 304 additions and 256 deletions
|
@ -1,3 +1,17 @@
|
|||
2004-02-09 Bogdan Gheorghe
|
||||
PR 51232
|
||||
|
||||
- Added a layer of separation between the parser and the indexer: we now
|
||||
create a worker thread to run the parser in. This allows the indexer to
|
||||
finish all scheduled jobs regardless of how the parser performs on
|
||||
individual files (i.e. indexing no longer affected by parser failures)
|
||||
|
||||
- Modified some of the stored index block reading routines to use separate
|
||||
counters, thus avoiding potential EOF exceptions.
|
||||
|
||||
* index/org/eclipse/cdt/internal/core/index/impl/BlocksIndexInput.java
|
||||
* index/org/eclipse/cdt/internal/core/index/search/indexing/SourceIndexer.java
|
||||
|
||||
2004-02-03 Alain Magloire
|
||||
|
||||
PR 51106
|
||||
|
|
|
@ -30,6 +30,7 @@ public class BlocksIndexInput extends IndexInput {
|
|||
protected FileListBlock currentFileListBlock;
|
||||
protected int currentFileListBlockNum;
|
||||
protected int currentIndexBlockNum;
|
||||
protected int currentIncludeBlockNum;
|
||||
protected IndexBlock currentIndexBlock;
|
||||
protected IndexBlock currentIncludeIndexBlock;
|
||||
private RandomAccessFile raf;
|
||||
|
@ -408,7 +409,7 @@ public class BlocksIndexInput extends IndexInput {
|
|||
//if end of the current block, we load the next one.
|
||||
boolean endOfBlock= !currentIncludeIndexBlock.nextEntry(currentIncludeEntry);
|
||||
if (endOfBlock) {
|
||||
currentIncludeIndexBlock= getIndexBlock(++currentIndexBlockNum);
|
||||
currentIncludeIndexBlock= getIndexBlock(++currentIncludeBlockNum);
|
||||
currentIncludeIndexBlock.nextEntry(currentWordEntry);
|
||||
}
|
||||
}
|
||||
|
@ -418,8 +419,8 @@ public class BlocksIndexInput extends IndexInput {
|
|||
protected void setFirstInclude() throws IOException {
|
||||
includePosition= 1;
|
||||
if (getNumIncludes() > 0) {
|
||||
currentIndexBlockNum= summary.getFirstIncludeBlockNum();
|
||||
currentIncludeIndexBlock= getIndexBlock(currentIndexBlockNum);
|
||||
currentIncludeBlockNum= summary.getFirstIncludeBlockNum();
|
||||
currentIncludeIndexBlock= getIndexBlock(currentIncludeBlockNum);
|
||||
currentIncludeEntry= new IncludeEntry(0);
|
||||
currentIncludeIndexBlock.reset();
|
||||
currentIncludeIndexBlock.nextEntry(currentIncludeEntry);
|
||||
|
|
|
@ -97,7 +97,18 @@ public class SourceIndexer extends AbstractIndexer {
|
|||
{
|
||||
}
|
||||
|
||||
boolean retVal = parser.parse();
|
||||
ParserRunner p = new ParserRunner(parser);
|
||||
Thread t = new Thread(p, "CDT Indexer Parser Runner");
|
||||
t.start();
|
||||
|
||||
try{
|
||||
t.join();
|
||||
}
|
||||
catch (InterruptedException e){
|
||||
org.eclipse.cdt.internal.core.model.Util.log(null, "Parser Runner InterruptedException - file: " + resourceFile.getFullPath(), ICLogConstants.CDT);
|
||||
}
|
||||
|
||||
boolean retVal = p.getResult();
|
||||
|
||||
if (!retVal)
|
||||
org.eclipse.cdt.internal.core.model.Util.log(null, "Failed to index " + resourceFile.getFullPath(), ICLogConstants.CDT);
|
||||
|
@ -120,4 +131,26 @@ public class SourceIndexer extends AbstractIndexer {
|
|||
public IFile getResourceFile() {
|
||||
return resourceFile;
|
||||
}
|
||||
|
||||
class ParserRunner implements Runnable {
|
||||
IParser parser;
|
||||
boolean retVal;
|
||||
ParserRunner(IParser parser){
|
||||
this.parser = parser;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
public void run() {
|
||||
try{
|
||||
retVal=parser.parse();
|
||||
}
|
||||
catch (Exception e){
|
||||
org.eclipse.cdt.internal.core.model.Util.log(null, "Parser Runner Exception " + resourceFile.getFullPath() + " Message: " + e.getMessage(), ICLogConstants.CDT);
|
||||
}
|
||||
}
|
||||
|
||||
boolean getResult(){ return retVal;}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue