Skip to content

Commit

Permalink
play with job priorities and scheduling rule
Browse files Browse the repository at this point in the history
  • Loading branch information
JPMoresmau committed Oct 14, 2011
1 parent 71a13cd commit 0f2eda4
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 33 deletions.
Expand Up @@ -391,7 +391,14 @@ private boolean parseNotes(JSONArray notes,Set<IResource> ress){
int col=ol.getInt("c");
Location loc=new Location(f, line, col, line, col);
Note n=new Note(k,loc,o.getString("t"),"");
final IResource res=project.findMember(f);
IResource res=project.findMember(f);
// if (res==null){
// f=f.replace("\\\\", "\\");
// String pos=project.getLocation().toOSString();
// if (f.startsWith(pos)){
// res=project.findMember(f.substring(pos.length()));
// }
// }
if (res!=null){
if (ress.add(res)){
BuildWrapperPlugin.deleteProblems(res);
Expand Down
Expand Up @@ -145,19 +145,19 @@ public static void logStatus(IStatus status) {
/**
* Delete all problem markers for a given file.
*
* @param r A resource that should be a file.
* @param r A resource that could be a file or a project.
*/
public static void deleteProblems(IResource r) {
if (!r.getWorkspace().isTreeLocked() && r.exists() && r.getProject().isOpen()) {
try {
if (r instanceof IFile) {
r.refreshLocal(IResource.DEPTH_ZERO, new NullProgressMonitor());
}
// if (r instanceof IFile) {
// r.refreshLocal(IResource.DEPTH_ZERO, new NullProgressMonitor());
// }
//org.eclipse.core.resources.problemmarker
r.deleteMarkers(PROBLEM_MARKER_ID, true, IResource.DEPTH_ZERO);
r.deleteMarkers("net.sf.eclipsefp.haskell.scion.client.ScionPlugin.projectProblem", true, IResource.DEPTH_ZERO);
r.deleteMarkers("net.sf.eclipsefp.haskell.core.scionProblem", true, IResource.DEPTH_ZERO);
r.deleteMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ZERO);
r.deleteMarkers(IMarker.PROBLEM, false, IResource.DEPTH_ZERO); // delete problems but not subtypes (HLint, etc are not managed by us)
} catch (CoreException ex) {
BuildWrapperPlugin.logError(BWText.error_deleteMarkers, ex);
ex.printStackTrace();
Expand Down
Expand Up @@ -2,7 +2,6 @@

import java.util.List;

import net.sf.eclipsefp.haskell.buildwrapper.types.BWTarget;
import net.sf.eclipsefp.haskell.buildwrapper.types.BuildOptions;
import net.sf.eclipsefp.haskell.buildwrapper.types.Location;
import net.sf.eclipsefp.haskell.buildwrapper.types.OccurrencesHandler;
Expand Down Expand Up @@ -83,65 +82,65 @@ protected IStatus run(IProgressMonitor monitor) {
return Status.OK_STATUS;
}
};
buildJob.setRule( getProject() );
buildJob.setPriority(Job.INTERACTIVE);
buildJob.setRule( f );
buildJob.setPriority(Job.SHORT);
buildJob.schedule();
}

public void updateFromEditor(final IFile f,final IDocument doc,final OutlineHandler handler){
public void updateFromEditor(final IFile file,final IDocument doc,final OutlineHandler handler){
final String jobNamePrefix = NLS.bind(BWText.editor_job_name, getProject().getName());

Job buildJob = new Job (jobNamePrefix) {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
monitor.beginTask(jobNamePrefix, IProgressMonitor.UNKNOWN);
long t0=System.currentTimeMillis();
//long t0=System.currentTimeMillis();
/*if (doc!=null){
realFacade.write(f, doc.get()); // the write is done by ScionTokenScanner
}*/
long t1=System.currentTimeMillis();
boolean buildOK= realFacade.build1(f);
//long t1=System.currentTimeMillis();
boolean buildOK= realFacade.build1(file);

long t2=System.currentTimeMillis();
//long t2=System.currentTimeMillis();

List<OutlineDef> defs=realFacade.outline(f);
long t3=System.currentTimeMillis();
List<OutlineDef> defs=realFacade.outline(file);
//long t3=System.currentTimeMillis();
if (defs.size()>0 && buildOK){
handler.handleOutline(defs); // avoid removing all outline on error
}

long t4=System.currentTimeMillis();
BuildWrapperPlugin.logInfo("write:"+(t1-t0)+"ms,outline:"+(t3-t2)+"ms,handleroutline:"+(t4-t3)+"ms,build:"+(t2-t1)+"ms");
//long t4=System.currentTimeMillis();
//BuildWrapperPlugin.logInfo("write:"+(t1-t0)+"ms,outline:"+(t3-t2)+"ms,handleroutline:"+(t4-t3)+"ms,build:"+(t2-t1)+"ms");
} finally {
monitor.done();
}
return Status.OK_STATUS;
}
};
buildJob.setRule( getProject() );
buildJob.setPriority(Job.DECORATE);
buildJob.setRule( file );
buildJob.setPriority(Job.SHORT);
buildJob.schedule();
}

public void getOccurrences(final IFile f,final String token,final OccurrencesHandler handler){
public void getOccurrences(final IFile file,final String token,final OccurrencesHandler handler){
final String jobNamePrefix = NLS.bind(BWText.occurrences_job_name, getProject().getName());

Job buildJob = new Job (jobNamePrefix) {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
monitor.beginTask(jobNamePrefix, IProgressMonitor.UNKNOWN);
handler.handleOccurrences(realFacade.getOccurrences(f, token));
handler.handleOccurrences(realFacade.getOccurrences(file, token));

} finally {
monitor.done();
}
return Status.OK_STATUS;
}
};
buildJob.setRule( getProject() );
buildJob.setPriority(Job.DECORATE);
buildJob.setRule( file );
buildJob.setPriority(Job.SHORT);
buildJob.schedule();
}

Expand All @@ -162,8 +161,8 @@ protected IStatus run(IProgressMonitor monitor) {
return Status.OK_STATUS;
}
};
buildJob.setRule( getProject() );
buildJob.setPriority(Job.DECORATE);
buildJob.setRule( file );
buildJob.setPriority(Job.SHORT);
buildJob.schedule();
}

Expand Down
Expand Up @@ -78,13 +78,13 @@ public void applyAsMarker(IResource resource,int maxLines) throws CoreException
/**
* this causes scheduling rule issues sometimes
*/
if (!resource.getWorkspace().isTreeLocked()){
try {
resource.refreshLocal(0, new NullProgressMonitor());
} catch (CoreException ce){
// ignore
}
}
// if (!resource.getWorkspace().isTreeLocked()){
// try {
// resource.refreshLocal(0, new NullProgressMonitor());
// } catch (CoreException ce){
// // ignore
// }
// }

int severity;
switch (kind) {
Expand Down

0 comments on commit 0f2eda4

Please sign in to comment.