Interface JobScheduler

All Known Implementing Classes:
ImmediateJobScheduler, OperationInitializerJobScheduler, UpdateGraphJobScheduler

public interface JobScheduler
An interface for submitting jobs to be executed. Submitted jobs may be executed on the current thread, or in separate threads (thus allowing true parallelism). Performance metrics are accumulated for all executions off the current thread for inclusion in overall task metrics.
  • Field Details

  • Method Details

    • submit

      void submit(ExecutionContext executionContext, Runnable runnable, LogOutputAppendable description, Consumer<Exception> onError)
      Cause runnable to be executed.
      Parameters:
      executionContext - the execution context to run it under
      runnable - the runnable to execute
      description - a description for logging
      onError - a routine to call if an exception occurs while running runnable
    • getAccumulatedPerformance

      BasePerformanceEntry getAccumulatedPerformance()
      The performance statistics of all runnables that have been completed off-thread, or null if all were executed in the current thread.
    • threadCount

      int threadCount()
      How many threads exist in the job scheduler? The job submitters can use this value to determine how many sub-jobs to split work into.
    • iterateParallel

      @FinalDefault default <CONTEXT_TYPE extends JobScheduler.JobThreadContext> void iterateParallel(@Nullable @Nullable ExecutionContext executionContext, @Nullable @Nullable LogOutputAppendable description, @NotNull @NotNull Supplier<CONTEXT_TYPE> taskThreadContextFactory, int start, int count, @NotNull @NotNull JobScheduler.IterateAction<CONTEXT_TYPE> action, @NotNull @NotNull Runnable onComplete, @NotNull @NotNull Consumer<Exception> onError)
      Provides a mechanism to iterate over a range of values in parallel using the JobScheduler
      Parameters:
      executionContext - the execution context for this task
      description - the description to use for logging
      taskThreadContextFactory - the factory that supplies contexts for the threads handling the sub-tasks
      start - the integer value from which to start iterating
      count - the number of times this task should be called
      action - the task to perform, the current iteration index is provided as a parameter
      onComplete - this will be called when all iterations are complete
      onError - error handler for the scheduler to use while iterating
    • iterateParallel

      @FinalDefault default <CONTEXT_TYPE extends JobScheduler.JobThreadContext> void iterateParallel(@Nullable @Nullable ExecutionContext executionContext, @Nullable @Nullable LogOutputAppendable description, @NotNull @NotNull Supplier<CONTEXT_TYPE> taskThreadContextFactory, int start, int count, @NotNull @NotNull JobScheduler.IterateResumeAction<CONTEXT_TYPE> action, @NotNull @NotNull Runnable onComplete, @NotNull @NotNull Consumer<Exception> onError)
      Provides a mechanism to iterate over a range of values in parallel using the JobScheduler. The advantage to using this over the other method is the resumption callable on action that will trigger the next execution. This allows the next iteration and the completion runnable to be delayed until dependent asynchronous serial or parallel scheduler jobs have completed.
      Parameters:
      executionContext - the execution context for this task
      description - the description to use for logging
      taskThreadContextFactory - the factory that supplies contexts for the tasks
      start - the integer value from which to start iterating
      count - the number of times this task should be called
      action - the task to perform, the current iteration index and a resume Runnable are parameters
      onComplete - this will be called when all iterations are complete
      onError - error handler for the scheduler to use while iterating
    • iterateSerial

      @FinalDefault default <CONTEXT_TYPE extends JobScheduler.JobThreadContext> void iterateSerial(@Nullable @Nullable ExecutionContext executionContext, @Nullable @Nullable LogOutputAppendable description, @NotNull @NotNull Supplier<CONTEXT_TYPE> taskThreadContextFactory, int start, int count, @NotNull @NotNull JobScheduler.IterateResumeAction<CONTEXT_TYPE> action, @NotNull @NotNull Runnable onComplete, @NotNull @NotNull Consumer<Exception> onError)
      Provides a mechanism to iterate over a range of values serially using the JobScheduler. The advantage to using this over a simple iteration is the resumption callable on action that will trigger the next execution. This allows the next iteration and the completion runnable to be delayed until dependent asynchronous serial or parallel scheduler jobs have completed.
      Parameters:
      executionContext - the execution context for this task
      description - the description to use for logging
      taskThreadContextFactory - the factory that supplies contexts for the tasks
      start - the integer value from which to start iterating
      count - the number of times this task should be called
      action - the task to perform, the current iteration index and a resume Runnable are parameters
      onComplete - this will be called when all iterations are complete
      onError - error handler for the scheduler to use while iterating