Commit 19d0490a authored by Kristof Szabados's avatar Kristof Szabados
Browse files

it is possible for several threads to add elements at the same time.


Signed-off-by: Kristof Szabados's avatarKristof Szabados <Kristof.Szabados@ericsson.com>
parent 27b20ac2
...@@ -16,6 +16,7 @@ import java.util.Iterator; ...@@ -16,6 +16,7 @@ import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
...@@ -757,13 +758,13 @@ public final class ProjectSourceParser { ...@@ -757,13 +758,13 @@ public final class ProjectSourceParser {
TITANDebugConsole.println("On-the-fly analyzation of project " + project.getName() + " started"); TITANDebugConsole.println("On-the-fly analyzation of project " + project.getName() + " started");
} }
final List<IProject> tobeSemanticallyAnalyzed = new ArrayList<IProject>();
try { try {
final boolean useParallelSemanticChecking = preferenceService.getBoolean( final boolean useParallelSemanticChecking = preferenceService.getBoolean(
ProductConstants.PRODUCT_ID_DESIGNER, ProductConstants.PRODUCT_ID_DESIGNER,
PreferenceConstants.USEPARALLELSEMATICCHECKING, true, null); PreferenceConstants.USEPARALLELSEMATICCHECKING, true, null);
if (useParallelSemanticChecking) { if (useParallelSemanticChecking) {
final ConcurrentLinkedQueue<IProject> tobeSemanticallyAnalyzed = new ConcurrentLinkedQueue<IProject>();
final ExecutorService executor = Executors.newCachedThreadPool(new ThreadFactory() { final ExecutorService executor = Executors.newCachedThreadPool(new ThreadFactory() {
@Override @Override
public Thread newThread(final Runnable r) { public Thread newThread(final Runnable r) {
...@@ -828,7 +829,11 @@ public final class ProjectSourceParser { ...@@ -828,7 +829,11 @@ public final class ProjectSourceParser {
ErrorReporter.logExceptionStackTrace(e); ErrorReporter.logExceptionStackTrace(e);
} }
executor.shutdownNow(); executor.shutdownNow();
ProjectSourceSemanticAnalyzer.analyzeMultipleProjectsSemantically(new ArrayList<IProject>(tobeSemanticallyAnalyzed), progress.newChild(tobeAnalyzed.size()), compilationCounter);
} else { } else {
final ArrayList<IProject> tobeSemanticallyAnalyzed = new ArrayList<IProject>();
for (final IProject tempProject : tobeAnalyzed) { for (final IProject tempProject : tobeAnalyzed) {
if (progress.isCanceled()) { if (progress.isCanceled()) {
throw new OperationCanceledException(); throw new OperationCanceledException();
...@@ -858,9 +863,9 @@ public final class ProjectSourceParser { ...@@ -858,9 +863,9 @@ public final class ProjectSourceParser {
progress.worked(1); progress.worked(1);
} }
} }
}
ProjectSourceSemanticAnalyzer.analyzeMultipleProjectsSemantically(tobeSemanticallyAnalyzed, progress.newChild(tobeAnalyzed.size()), compilationCounter); ProjectSourceSemanticAnalyzer.analyzeMultipleProjectsSemantically(tobeSemanticallyAnalyzed, progress.newChild(tobeAnalyzed.size()), compilationCounter);
}
// semantic check for config file // semantic check for config file
// GlobalParser.getConfigSourceParser(project).doSemanticCheck(); // GlobalParser.getConfigSourceParser(project).doSemanticCheck();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment