Skip to content

Unity JobSystem schedule pattern #7773

Description

@RatmmmhSquishyRat

What problem does this solve or what need does it fill?

Sometimes I don't really need the ECS framework but only need the schedule, for example:

  1. Plan all the tasks in a heavy-computation framework such as voxel generation for one generation requirement and run it, the framework generation process should be seen as a whole single system.
  2. Push tasks and generate the tasks dependency graph dynamically in one planning system and run the graph, once per frame. It's for situations like complex damage and effect dealing between characters.

What solution would you like?

Let the user have the ability to fully determine the behavior of the scheduling tool.

Example:

fn task1()...

fn plan1_system(mut commands: Commands){
    commands.spawn(MyTask::new(task1));
    ...
}
fn schedule_system(tasks: Query<&MyTask>,mut scheduler: Scheduler) {
    for task in tasks{scheduler(task,task.dependency); }
    scheduler.complete();//The system completes when the graph completes.
} 
fn main(){
    App::new().add_system(...)
    ...
    .add_system(
        schedule_system
     .after(Label::BeforeExecution))
     .before(Label::AfterExecution)
    )
    .add_system(...)
    ...
}

What alternative(s) have you considered?

#4090 I find the method run_schedule in this issue useful but the current World struct doesn't have it in bevy 0.9.1.
#7707 use commands to add one-shot systems but it seems only to support sequential execution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsA-TasksTools for parallel and async workC-FeatureA new feature, making something new possible

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions