-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Create a single-threaded stage type that immediately applies commands (and other buffers) after every system #2429
Description
What problem does this solve or what need does it fill?
In some games (or other applications of bevy_ecs), system parallelization is not critical: the game may not be performance constrained, the work may be done entirely on non-send resources (such as for scripting language integrations), or better opportunities for parallelism may exist within the system.
In this case, a single-threaded, imperative system execution strategy is the natural solution, which is much simpler to write and reason about, and can eliminate the delay in command processing that can make prototyping frustrating.
EDIT: as discussed below, this should be a new abstraction, rather than a modification to existing single-threaded stages.
What solution would you like?
Create a new "immediate" stage type that applies buffers immediately after running each system. This may also require creating a corresponding executor to run it.
Use SystemState::new(world) and then SystemState::apply() to immediately flush all buffers after the system is run, removing the delay on commands.
Additional context
Workaround for #1613, but comes at the heavy cost of eliminating system parallelism.
#2381 provides similar functionality for specifying linear ordering of systems within parallel stages, but does not immediately apply buffers.