Class GraphJobRunner

java.lang.Object
ghidra.graph.job.GraphJobRunner
All Implemented Interfaces:
GraphJobListener

public class GraphJobRunner extends Object implements GraphJobListener
A class to run GraphJobs. This class will queue jobs and will run them in the Swing thread. Job implementations may be multi-threaded, as they choose, by managing threads themselves. This is different than a typical job runner, which is usually itself threaded.

A job is considered finished when jobFinished(GraphJob) is called on this class. After this callback, the next job will be run.

setFinalJob(GraphJob) sets a job to be run last, after all jobs in the queue have finished.

When a job is added via schedule(GraphJob), any currently running job will be told to finish immediately, if it's GraphJob.canShortcut() returns true. If it cannot be shortcut, then it will be allowed to finish. Further, this logic will be applied to each job in the queue. So, if there are multiple jobs in the queue, which all return true for GraphJob.canShortcut(), then they will each be shortcut (allowing them to complete) before running the newly scheduled job.

This class is thread-safe in that you can schedule(GraphJob) jobs from any thread.

Synchronization Policy: the methods that mutate fields of this class or read them must be synchronized.

  • Constructor Details

    • GraphJobRunner

      public GraphJobRunner()
  • Method Details

    • schedule

      public void schedule(GraphJob job)
    • setFinalJob

      public void setFinalJob(GraphJob job)
      Sets a job to run after all currently running and queued jobs. If a final job was already set, then that job will be replaced with the given job.
      Parameters:
      job - the job to run
    • isBusy

      public boolean isBusy()
    • finishAllJobs

      public void finishAllJobs()
      Causes all jobs to be finished as quickly as possible, calling GraphJob.shortcut() on each job.

      Note: some jobs are not shortcut-able and will finish on their own time. Any jobs queued behind a non-shortcut-able job will not be shortcut.

      See Also:
    • dispose

      public void dispose()
      Clears any pending jobs, stops the currently running job ungracefully and updates this class so that any new jobs added will be ignored.
    • jobFinished

      public void jobFinished(GraphJob job)
      Specified by:
      jobFinished in interface GraphJobListener