Issue #21 resolved

Controller overhaul

Michael Ludwig
repo owner created an issue

The ControllerManager and Controller model are reasonable, but are somewhat underpowered.

Here are changes that should be made:

  1. Controller is renamed to Task. Its preProcess() and postProcess() methods are replaced with a single reset() method.
  2. process() returns a nullable Task that is invoked as a post-process after the job.
  3. Tasks are collected into a Job. Results reported by tasks are only delivered to tasks within the same job.
  4. Tasks can implement a ParallelAware interface that describes component types that are added/removed, read/written, and if entities are added/removed.
    • Job acquires locks needed given the above, for all tasks and holds them for the duration of the task (ordered consistently to prevent deadblocks).
    • The post-process Tasks are invoked after the locks are released, within an implicit job wrapping all post-process tasks from the initial job.
    • This repeats until no further tasks need to be invoked.
  5. Jobs reset tasks before each execution of the job. When the job is created, it invokes init(), and destroy() when the job is GC'ed.
  6. There is a scheduler that has a fixed size thread pool. Jobs are queued and run on an available thread.
    • It also has a convenience interface for creating control threads that queue jobs at different rates, etc.
    • The scheduling interface for repeated job execution lets the programmer specify a conditional that is evaluated before queuing (e.g. pause game simulation, without pausing rendering).
  7. Add a convenience paradigm to the abstract task that looks for a processEntity() method that takes a number of ComponentData types as arguments.
    • It automatically allocates the ComponentData instances
    • Creates the ComponentIterator and invokes processEntity for each element
  8. Results are reported to other tasks by having those tasks expose on(T extends Result)
    • The methods are only invoked if the reported result is a subtype of the requested method
    • A task can listen for multiple results by having multiple methods with different result types

Comments (7)

  1. Log in to comment