Java Code Examples for org.eclipse.core.runtime.jobs.Job#SLEEPING

The following examples show how to use org.eclipse.core.runtime.jobs.Job#SLEEPING . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WaitUtils.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static String jobStateToString(int jobState) {
    switch (jobState) {
    case Job.RUNNING:
        return "RUNNING"; //$NON-NLS-1$
    case Job.WAITING:
        return "WAITING"; //$NON-NLS-1$
    case Job.SLEEPING:
        return "SLEEPING"; //$NON-NLS-1$
    case Job.NONE:
        return "NONE"; //$NON-NLS-1$
    default:
        return "UNKNOWN"; //$NON-NLS-1$
    }
}
 
Example 2
Source File: ThreadDumpingWatchdog.java    From google-cloud-eclipse with Apache License 2.0 4 votes vote down vote up
private static void dumpJob(StringBuilder sb, String linePrefix, Job job, Thread thread) {
  String status;
  switch (job.getState()) {
    case Job.RUNNING:
      status = "RUNNING";
      break;
    case Job.WAITING:
      status = "WAITING";
      break;
    case Job.SLEEPING:
      status = "SLEEPING";
      break;
    case Job.NONE:
      status = "NONE";
      break;
    default:
      status = "UNKNOWN(" + job.getState() + ")";
      break;
  }
  Object blockingJob = null;
  try {
    blockingJob = ReflectionUtil.invoke(Job.getJobManager(), "findBlockingJob",
        InternalJob.class, new Class<?>[] {InternalJob.class}, job);
  } catch (NoSuchMethodException | SecurityException | IllegalAccessException
      | IllegalArgumentException | InvocationTargetException ex) {
    System.err.println("Unable to fetch blocking-job: " + ex);
  }
  sb.append("\n").append(linePrefix);
  sb.append(
      String.format(
          "  %s%s{pri=%d%s%s%s%s} %s (%s)%s",
          status,
          (job.isBlocking() ? "<BLOCKING>" : ""),
          job.getPriority(),
          (job.isSystem() ? ",system" : ""),
          (job.isUser() ? ",user" : ""),
          (job.getRule() != null ? ",rule=" + job.getRule() : ""),
          (thread != null ? ",thr=" + thread : ""),
          job,
          job.getClass().getName(),
          (job.getJobGroup() != null ? " [group=" + job.getJobGroup() + "]" : "")));
  if (blockingJob != null) {
    sb.append("\n").append(linePrefix)
        .append(String.format("    - blocked by: %s (%s)", blockingJob, blockingJob.getClass()));
  }
}
 
Example 3
Source File: TexlipseBuilder.java    From texlipse with Eclipse Public License 1.0 4 votes vote down vote up
/**
    * Build the project.
    * 
 * @see IncrementalProjectBuilder.build
 */
   @Override
protected IProject[] build(int kind, Map args,
        IProgressMonitor monitor) throws CoreException {

       final IProject project = getProject();
       final ProjectFileTracking fileTracking = new ProjectFileTracking(project);
       final OutputFileManager fileManager = new OutputFileManager(project, fileTracking);

       Object rebuild = TexlipseProperties.getSessionProperty(project,
               TexlipseProperties.FORCED_REBUILD);

       // Wait for all scheduled parser jobs, since they could change relevant
       // session properties
       for (Job parser : Job.getJobManager().find(TexDocumentModel.PARSER_FAMILY)) {
           int state = parser.getState();
           if (state == Job.WAITING || state == Job.SLEEPING) {
               // If waiting, run immediately
               parser.cancel();
               parser.schedule();
           }
           try {
               parser.join();
           } catch (InterruptedException e) {
           }
       }

       if (rebuild == null && fileManager.isUpToDate()) {
           return null;
       }

       BuilderRegistry.clearConsole();

       Object s = TexlipseProperties.getProjectProperty(project,
               TexlipseProperties.PARTIAL_BUILD_PROPERTY);
	if (s != null) {
		partialBuild(project, fileManager, monitor);
	} else {
		buildFile(project, null, fileManager, monitor);
	}

	TexlipseProperties.setSessionProperty(project,
	        TexlipseProperties.FORCED_REBUILD, null);

	return null;
}