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.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Helper interface foriterateSerial()
anditerateParallel()
.static interface
Helper interface foriterateSerial(io.deephaven.engine.context.ExecutionContext, io.deephaven.base.log.LogOutputAppendable, java.util.function.Supplier<CONTEXT_TYPE>, int, int, io.deephaven.engine.table.impl.util.JobScheduler.IterateResumeAction<CONTEXT_TYPE>, java.lang.Runnable, java.util.function.Consumer<java.lang.Exception>)
anditerateParallel(io.deephaven.engine.context.ExecutionContext, io.deephaven.base.log.LogOutputAppendable, java.util.function.Supplier<CONTEXT_TYPE>, int, int, io.deephaven.engine.table.impl.util.JobScheduler.IterateAction<CONTEXT_TYPE>, java.lang.Runnable, java.util.function.Consumer<java.lang.Exception>)
.static final class
static interface
A default context for the scheduled job actions. -
Field Summary
Modifier and TypeFieldDescriptionstatic final JobScheduler.JobThreadContext
static final Supplier<JobScheduler.JobThreadContext>
-
Method Summary
Modifier and TypeMethodDescriptionThe performance statistics of all runnables that have been completed off-thread, or null if all were executed in the current thread.default <CONTEXT_TYPE extends JobScheduler.JobThreadContext>
voiditerateParallel
(@Nullable ExecutionContext executionContext, @Nullable LogOutputAppendable description, @NotNull Supplier<CONTEXT_TYPE> taskThreadContextFactory, int start, int count, @NotNull JobScheduler.IterateAction<CONTEXT_TYPE> action, @NotNull Runnable onComplete, @NotNull Consumer<Exception> onError) Provides a mechanism to iterate over a range of values in parallel using theJobScheduler
default <CONTEXT_TYPE extends JobScheduler.JobThreadContext>
voiditerateParallel
(@Nullable ExecutionContext executionContext, @Nullable LogOutputAppendable description, @NotNull Supplier<CONTEXT_TYPE> taskThreadContextFactory, int start, int count, @NotNull JobScheduler.IterateResumeAction<CONTEXT_TYPE> action, @NotNull Runnable onComplete, @NotNull Consumer<Exception> onError) Provides a mechanism to iterate over a range of values in parallel using theJobScheduler
.default <CONTEXT_TYPE extends JobScheduler.JobThreadContext>
voiditerateSerial
(@Nullable ExecutionContext executionContext, @Nullable LogOutputAppendable description, @NotNull Supplier<CONTEXT_TYPE> taskThreadContextFactory, int start, int count, @NotNull JobScheduler.IterateResumeAction<CONTEXT_TYPE> action, @NotNull Runnable onComplete, @NotNull Consumer<Exception> onError) Provides a mechanism to iterate over a range of values serially using theJobScheduler
.void
submit
(ExecutionContext executionContext, Runnable runnable, LogOutputAppendable description, Consumer<Exception> onError) Cause runnable to be executed.int
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.
-
Field Details
-
DEFAULT_CONTEXT
-
DEFAULT_CONTEXT_FACTORY
-
-
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 underrunnable
- the runnable to executedescription
- a description for loggingonError
- 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 theJobScheduler
- Parameters:
executionContext
- the execution context for this taskdescription
- the description to use for loggingtaskThreadContextFactory
- the factory that suppliescontexts
for the threads handling the sub-tasksstart
- the integer value from which to start iteratingcount
- the number of times this task should be calledaction
- the task to perform, the current iteration index is provided as a parameteronComplete
- this will be called when all iterations are completeonError
- 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 theJobScheduler
. The advantage to using this over the other method is the resumption callable onaction
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 taskdescription
- the description to use for loggingtaskThreadContextFactory
- the factory that suppliescontexts
for the tasksstart
- the integer value from which to start iteratingcount
- the number of times this task should be calledaction
- the task to perform, the current iteration index and a resume Runnable are parametersonComplete
- this will be called when all iterations are completeonError
- 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 theJobScheduler
. The advantage to using this over a simple iteration is the resumption callable onaction
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 taskdescription
- the description to use for loggingtaskThreadContextFactory
- the factory that suppliescontexts
for the tasksstart
- the integer value from which to start iteratingcount
- the number of times this task should be calledaction
- the task to perform, the current iteration index and a resume Runnable are parametersonComplete
- this will be called when all iterations are completeonError
- error handler for the scheduler to use while iterating
-