bevy/crates/bevy_ecs/src/query
Chris Russell 5f4b5a37f1
Support declaring resource access in Queries. (#16843)
# Objective

Allow resources to be accessed soundly by `QueryData` and `QueryFilter`
implementations.

This mostly works today, and is used in `bevy-trait-query` and will be
used by #16810. The problem is that the access is not made visible to
the executor, so it would be possible for a system with resource access
in a query to run concurrently with a system that accesses the resource
with `ResMut`, resulting in Undefined Behavior.

## Solution

Define calling `add_resource_read` or `add_resource_write` in
`WorldQuery::update_component_access` to be a supported way to declare
resource access in a query.
Modify `QueryState::new_with_access` to check for resource access and
report it in `archetype_component_acccess`.
Modify `FilteredAccess::is_compatible` to consider resource access
conflicting even on queries with disjoint filters.
2024-12-17 00:03:20 +00:00
..
access.rs Support declaring resource access in Queries. (#16843) 2024-12-17 00:03:20 +00:00
builder.rs Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
error.rs Deny derive_more error feature and replace it with thiserror (#16684) 2024-12-06 17:03:55 +00:00
fetch.rs Add Immutable Component Support (#16372) 2024-12-05 14:27:48 +00:00
filter.rs Move all_tuples to a new crate (#16161) 2024-12-03 17:41:09 +00:00
iter.rs implement the full set of sorts on QueryManyIter (#13443) 2024-12-03 17:02:37 +00:00
mod.rs Support declaring resource access in Queries. (#16843) 2024-12-17 00:03:20 +00:00
par_iter.rs Fix query transmute from table to archetype iteration unsoundness (#14615) 2024-08-27 00:58:40 +00:00
state.rs Support declaring resource access in Queries. (#16843) 2024-12-17 00:03:20 +00:00
world_query.rs Support declaring resource access in Queries. (#16843) 2024-12-17 00:03:20 +00:00