Permalink
Browse files

close on processes on clean and shutdown

  • Loading branch information...
JPMoresmau committed Feb 7, 2013
1 parent 6de8b61 commit a81fe7796dc2875d510477fe225d1c72cea23cb6
@@ -8,6 +8,7 @@
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -102,7 +103,7 @@
* where ever we come from, we only launch one synchronize operation per file at a time, and lose the intermediate operations
*/
private Map<IFile,SingleJobQueue> syncEditorJobQueue=new HashMap<IFile, SingleJobQueue>();
- private Map<IFile,Process> buildProcesses=new HashMap<IFile, Process>();
+ private Map<IFile,Process> buildProcesses=Collections.synchronizedMap(new HashMap<IFile, Process>());
/**
* query for thing at point for a given file, so that we never have more than two jobs at one time
@@ -1313,6 +1314,11 @@ public void setProject(IProject project) {
*/
public void clean(IProgressMonitor mon) throws CoreException{
if (project!=null){
+ /**
+ * closes processes so they don't have locks on resources we'd like to delete
+ * and they can then be restarted with the newly generated files
+ */
+ closeAllProcesses();
IFolder fldr=project.getFolder(DIST_FOLDER);
if (fldr.exists()){
fldr.delete(IResource.FORCE, mon);
@@ -1325,6 +1331,18 @@ public void clean(IProgressMonitor mon) throws CoreException{
}
}
+ /**
+ * close all long running processes
+ */
+ public void closeAllProcesses(){
+ // copy since endLongRunning removes from the map
+ IFile[] fs=buildProcesses.keySet().toArray(new IFile[buildProcesses.size()]);
+ for (IFile f:fs){
+ endLongRunning(f);
+ }
+ buildProcesses.clear();
+ }
+
/**
* set dist folder as derived so that it will be ignored in searches, etc.
*/
@@ -92,6 +92,7 @@ public void stop(BundleContext context) throws Exception {
for (SingleJobQueue q:f.getEditorSynchronizeJobQueues()){
q.close();
}
+ f.closeAllProcesses();
}
usageThread.setShouldStop();

0 comments on commit a81fe77

Please sign in to comment.