Interface JavaScriptJobManager

All Superinterfaces:
Serializable
All Known Implementing Classes:
JavaScriptJobManagerImpl

public interface JavaScriptJobManager extends Serializable
A manager for JavaScriptJobs.
  • Method Details

    • getJobCount

      int getJobCount()
      Returns the number of active jobs, including jobs that are currently executing and jobs that are waiting to execute.
      Returns:
      the number of active jobs
    • getJobCount

      Returns the number of active jobs, including jobs that are currently executing and jobs that are waiting to execute. Only jobs passing the filter are counted.
      Parameters:
      filter - the JavaScriptJobFilter
      Returns:
      the number of active jobs
    • addJob

      int addJob(JavaScriptJob job, Page page)
      Adds the specified job to this job manager, assigning it an ID. If the specified page is not currently loaded in the window which owns this job manager, the operation fails and this method returns 0.
      Parameters:
      job - the job to add to the job manager
      page - the page which is trying to add the job
      Returns:
      the ID assigned to the job
    • removeJob

      void removeJob(int id)
      Removes the specified job from the execution queue. This doesn't interrupt the job if it is currently running.
      Parameters:
      id - the ID of the job to be removed from the execution queue
    • removeAllJobs

      void removeAllJobs()
      Removes all jobs from the execution queue. This doesn't interrupt any jobs that may be currently running.
    • stopJob

      void stopJob(int id)
      Stops the specified job and removes it from the execution queue, not even allowing the job to finish if it is currently executing.
      Parameters:
      id - the ID of the job to be stopped
    • waitForJobs

      int waitForJobs(long timeoutMillis)
      Blocks until all active jobs have finished executing. If a job is scheduled to begin executing after (now + timeoutMillis), this method will wait for timeoutMillis milliseconds and then return false.
      Parameters:
      timeoutMillis - the maximum amount of time to wait (in milliseconds); may be negative, in which case this method returns immediately
      Returns:
      the number of background JavaScript jobs still executing or waiting to be executed when this method returns; will be 0 if there are no jobs left to execute
    • waitForJobsStartingBefore

      int waitForJobsStartingBefore(long delayMillis)
      Blocks until all jobs scheduled to start executing before (now + delayMillis) have finished executing. If there is no background JavaScript task currently executing, and there is no background JavaScript task scheduled to start executing within the specified time, this method returns immediately -- even if there are tasks scheduled to be executed after (now + delayMillis).
      Parameters:
      delayMillis - the delay which determines the background tasks to wait for (in milliseconds); may be negative, as it is relative to the current time
      Returns:
      the number of background JavaScript jobs still executing or waiting to be executed when this method returns; will be 0 if there are no jobs left to execute
    • waitForJobsStartingBefore

      int waitForJobsStartingBefore(long delayMillis, JavaScriptJobManager.JavaScriptJobFilter filter)
      Blocks until all jobs scheduled to start executing before (now + delayMillis) have finished executing. If there is no background JavaScript task currently executing, and there is no background JavaScript task scheduled to start executing within the specified time, this method returns immediately -- even if there are tasks scheduled to be executed after (now + delayMillis).
      Parameters:
      delayMillis - the delay which determines the background tasks to wait for (in milliseconds); may be negative, as it is relative to the current time
      filter - the JavaScriptJobFilter
      Returns:
      the number of background JavaScript jobs still executing or waiting to be executed when this method returns; will be 0 if there are no jobs left to execute
    • shutdown

      void shutdown()
      Shuts down this job manager and stops all of its jobs.
    • getEarliestJob

      JavaScriptJob getEarliestJob()
      Gets the earliest job for this manager.
      Returns:
      null if none
    • getEarliestJob

      Gets the earliest job for this manager.
      Parameters:
      filter - the JavaScriptJobFilter
      Returns:
      null if none
    • runSingleJob

      boolean runSingleJob(JavaScriptJob job)
      Runs the provided job if it is the right time for it.
      Parameters:
      job - the job to run
      Returns:
      returns true if the job was run.
    • jobStatusDump

      INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
      Utility method to report the current job status. Might help some tools.
      Parameters:
      filter - the JavaScriptJobFilter
      Returns:
      the job status report as string