Skip to content

Commit 075209e

Browse files
Merge pull request #110 from hymm/stage-yeet-cleanup-outer-schedules
add a method on add to create a simple outer schedule
2 parents 41d0b86 + e7f8cc2 commit 075209e

File tree

5 files changed

+20
-17
lines changed

5 files changed

+20
-17
lines changed

crates/bevy_app/src/app.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,20 @@ impl App {
529529
self
530530
}
531531

532+
/// adds a single threaded outer schedule to the [`App`] that just runs the main schedule
533+
pub fn add_simple_outer_schedule(&mut self) -> &mut Self {
534+
fn run_main_schedule(world: &mut World) {
535+
world.run_schedule(CoreSchedule::Main);
536+
}
537+
538+
self.edit_schedule(CoreSchedule::Outer, |schedule| {
539+
schedule.set_executor_kind(bevy_ecs::scheduling::ExecutorKind::SingleThreaded);
540+
schedule.add_system(run_main_schedule);
541+
});
542+
543+
self
544+
}
545+
532546
/// Setup the application to manage events of type `T`.
533547
///
534548
/// This is done by adding a [`Resource`] of type [`Events::<T>`],

crates/bevy_app/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ impl CoreSchedule {
7171
world.run_schedule(CoreSchedule::Main);
7272
}
7373

74-
/// Initializes a schedule for [`CoreSchedule::Outer`] that contains the [`outer_loop`] system.
74+
/// Initializes a single threaded schedule for [`CoreSchedule::Outer`] that contains the [`outer_loop`] system.
7575
pub fn outer_schedule() -> Schedule {
7676
let mut schedule = Schedule::new();
77+
schedule.set_executor_kind(bevy_ecs::scheduling::ExecutorKind::SingleThreaded);
7778
schedule.add_system(Self::outer_loop);
7879
schedule
7980
}

crates/bevy_render/src/lib.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ impl Plugin for RenderPlugin {
214214
let asset_server = app.world.resource::<AssetServer>().clone();
215215

216216
let mut render_app = App::empty();
217+
render_app.add_simple_outer_schedule();
217218
let mut render_schedule = RenderSet::base_schedule();
218219

219220
// Prepare the schedule which extracts data from the main world to the render world
@@ -238,13 +239,7 @@ impl Plugin for RenderPlugin {
238239

239240
render_schedule.add_system(World::clear_entities.in_set(RenderSet::Cleanup));
240241

241-
let mut outer_schedule = Schedule::new();
242-
outer_schedule.add_system(|world: &mut World| {
243-
world.run_schedule(CoreSchedule::Main);
244-
});
245-
246242
render_app
247-
.add_schedule(CoreSchedule::Outer, outer_schedule)
248243
.add_schedule(CoreSchedule::Main, render_schedule)
249244
.init_resource::<render_graph::RenderGraph>()
250245
.insert_resource(RenderInstance(instance))

crates/bevy_render/src/pipelined_rendering.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use async_channel::{Receiver, Sender};
22

33
use bevy_app::{App, AppLabel, CoreSchedule, Plugin, SubApp};
44
use bevy_ecs::{
5-
scheduling::{MainThreadExecutor, Schedule},
5+
scheduling::MainThreadExecutor,
66
system::Resource,
77
world::{Mut, World},
88
};
@@ -72,12 +72,8 @@ impl Plugin for PipelinedRenderingPlugin {
7272
app.insert_resource(MainThreadExecutor::new());
7373

7474
let mut sub_app = App::empty();
75+
sub_app.add_simple_outer_schedule();
7576
sub_app.init_schedule(CoreSchedule::Main);
76-
let mut outer_schedule = Schedule::new();
77-
outer_schedule.add_system(|world: &mut World| {
78-
world.run_schedule(CoreSchedule::Main);
79-
});
80-
sub_app.add_schedule(CoreSchedule::Outer, outer_schedule);
8177
app.insert_sub_app(RenderExtractApp, SubApp::new(sub_app, update_rendering));
8278
}
8379

crates/bevy_time/src/fixed_timestep.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@
2323
2424
use crate::Time;
2525
use bevy_app::CoreSchedule;
26-
use bevy_ecs::{
27-
system::Resource,
28-
world::{Mut, World},
29-
};
26+
use bevy_ecs::{system::Resource, world::World};
3027
use bevy_utils::Duration;
3128
use thiserror::Error;
3229

0 commit comments

Comments
 (0)