bevy/crates/bevy_ecs/Cargo.toml
James Liu e34fb68677
refactor: Extract parallel queue abstraction (#7348)
# Objective
There's a repeating pattern of `ThreadLocal<Cell<Vec<T>>>` which is very
useful for low overhead, low contention multithreaded queues that have
cropped up in a few places in the engine. This pattern is surprisingly
useful when building deferred mutation across multiple threads, as noted
by it's use in `ParallelCommands`.

However, `ThreadLocal<Cell<Vec<T>>>` is not only a mouthful, it's also
hard to ensure the thread-local queue is replaced after it's been
temporarily removed from the `Cell`.

## Solution
Wrap the pattern into `bevy_utils::Parallel<T>` which codifies the
entire pattern and ensures the user follows the contract. Instead of
fetching indivdual cells, removing the value, mutating it, and replacing
it, `Parallel::get` returns a `ParRef<'a, T>` which contains the
temporarily removed value and a reference back to the cell, and will
write the mutated value back to the cell upon being dropped.

I would like to use this to simplify the remaining part of #4899 that
has not been adopted/merged.

---

## Changelog
TODO

---------

Co-authored-by: Joseph <21144246+JoJoJet@users.noreply.github.com>
2024-02-19 16:31:15 +00:00

49 lines
1.2 KiB
TOML

[package]
name = "bevy_ecs"
version = "0.13.0"
edition = "2021"
description = "Bevy Engine's entity component system"
homepage = "https://bevyengine.org"
repository = "https://github.com/bevyengine/bevy"
license = "MIT OR Apache-2.0"
keywords = ["ecs", "game", "bevy"]
categories = ["game-engines", "data-structures"]
[features]
trace = []
multi-threaded = ["bevy_tasks/multi-threaded"]
bevy_debug_stepping = []
default = ["bevy_reflect", "bevy_debug_stepping"]
[dependencies]
bevy_ptr = { path = "../bevy_ptr", version = "0.13.0" }
bevy_reflect = { path = "../bevy_reflect", version = "0.13.0", optional = true }
bevy_tasks = { path = "../bevy_tasks", version = "0.13.0" }
bevy_utils = { path = "../bevy_utils", version = "0.13.0" }
bevy_ecs_macros = { path = "macros", version = "0.13.0" }
async-channel = "2.1.0"
fixedbitset = "0.4.2"
rustc-hash = "1.1"
downcast-rs = "1.2"
serde = "1"
thiserror = "1.0"
[dev-dependencies]
rand = "0.8"
static_assertions = "1.1.0"
[[example]]
name = "events"
path = "examples/events.rs"
[[example]]
name = "resources"
path = "examples/resources.rs"
[[example]]
name = "change_detection"
path = "examples/change_detection.rs"
[lints]
workspace = true