Skip to content

Commit

Permalink
Updated notes on manually running systems from &mut World
Browse files Browse the repository at this point in the history
  • Loading branch information
alice-i-cecile committed Jun 30, 2021
1 parent 3537668 commit 8a1e053
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions content/learn/book/ecs/exclusive-world-access/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,15 @@ app_exit_event_writer.send(AppExit);

### Manually running systems

With the help of [`SystemParamFunction::run()](https://docs.rs/bevy/0.5.0/bevy/ecs/system/trait.SystemParamFunction.html#tymethod.run), you can manually run systems of your own!
This can be useful if you want to implement your own, advanced work scheduling in a way that doesn't fit well into a standard stage.
FIXME: verify that https://github.com/bevyengine/bevy/pull/2417 was merged for 0.6.

TODO: add code demonstrating this here.
```rust
If you'd like to use the familiar and expressive system syntax when working with `World`, you can use the [`World::run_system`](https://docs.rs/bevy/0.5.0/bevy/ecs/world/struct.World.html#method.run_system) method to immediately execute one system at a time.
Commands generated by the system are applied immediately after it is executed in this way.

```
This will generally be less performant than using a standard parallel system stage,
but can offer greater simplicity and control, particularly when prototyping or for non-standard control flows.

Note that this function is `unsafe`: you need to be careful to ensure that your systems are not accessing mutable data in more than one place at once.
Running each of these systems sequentially will ensure this, and is often sufficient for basic applications of this pattern.
It can also be useful for re-using or organizing logic used in other areas where you need exclusive world access, by wrapping it in a safe and well-contained function that is run in a single line.

## Applications of exclusive world access

Expand Down

0 comments on commit 8a1e053

Please sign in to comment.