public interface Task
Schedulerwork together to coordinate the execution of collections of tasks. Tasks are grouped into jobs, where a job represents a logical step such as "render frame", or "compute physics", even if it is split into multiple tasks. Within a job, tasks are executed serially, but the scheduler can run different jobs simultaneously. The
ParallelAwarecan be used with tasks to restrict the contention points of a job. This is important because a job acquires the locks for each of its tasks before invoking the first task. The locks are not released until the last task has terminated. A task can communicate with the remaining tasks of a job by
reportingresults. The results are only reported to tasks within the owning job, and that are executed after the current task. Thus tasks that have already completed their processing will not receive new results. A task receives results by defining any number of methods with the signature
public void report(T extends Result). When a result is reported to the job, it will invoke using reflection any
report()method that takes a result of the compatible type. Task instances should only ever be used with a single job and entity system. If the task needs to be performed in multiple jobs or systems, new instances of the same type should be created.
|Modifier and Type||Method and Description|
Invoke task specific operations to process the EntitySystem.
Reset any internal storage within this Task in preparation for the next execution of its owning job.
Task process(EntitySystem system, Job job)
ParallelAware. If this task is not ParallelAware, the job acquires an exclusive lock with the assumption that it could modify anything. A task can return another task to be invoked after the owning job completes. These returned tasks are executed within their own set of locks, so it can be used to segment how long, and which locks are held by a job.
system- The EntitySystem being processed, which will always be the same for a given Task instance
job- The Job this task belongs to
void reset(EntitySystem system)
system- The EntitySystem that will be processed, which will always be the same for a given Task instance
Copyright © 2013. All Rights Reserved.