pub struct Access { /* private fields */ }Expand description
Describes the component access pattern for a query.
Used by the scheduler to determine which systems can run in parallel.
Implementations§
Source§impl Access
impl Access
Sourcepub fn add_read(&mut self, id: ComponentId)
pub fn add_read(&mut self, id: ComponentId)
Adds a read access for the given component.
Sourcepub fn add_write(&mut self, id: ComponentId)
pub fn add_write(&mut self, id: ComponentId)
Adds a write access for the given component.
Write access implies read access.
Sourcepub fn reads(&self) -> impl Iterator<Item = &ComponentId>
pub fn reads(&self) -> impl Iterator<Item = &ComponentId>
Returns all components that are read (including those also written).
Sourcepub fn writes(&self) -> &BTreeSet<ComponentId>
pub fn writes(&self) -> &BTreeSet<ComponentId>
Returns all components that are written.
Sourcepub fn reads_only(&self) -> impl Iterator<Item = &ComponentId>
pub fn reads_only(&self) -> impl Iterator<Item = &ComponentId>
Returns the set of read-only components (read but not written).
Sourcepub fn conflicts_with(&self, other: &Access) -> bool
pub fn conflicts_with(&self, other: &Access) -> bool
Checks if this access conflicts with another.
Two accesses conflict if:
- One writes to a component that the other reads or writes
- One writes to a resource that the other reads or writes
Sourcepub fn is_read_only(&self) -> bool
pub fn is_read_only(&self) -> bool
Returns true if this access pattern is read-only.
This checks component, resource, and non-send resource access.
Sourcepub fn add_resource_read(&mut self, id: ResourceId)
pub fn add_resource_read(&mut self, id: ResourceId)
Adds a read access for the given resource.
Sourcepub fn add_resource_write(&mut self, id: ResourceId)
pub fn add_resource_write(&mut self, id: ResourceId)
Adds a write access for the given resource.
Write access implies read access.
Sourcepub fn resource_reads(&self) -> impl Iterator<Item = &ResourceId>
pub fn resource_reads(&self) -> impl Iterator<Item = &ResourceId>
Returns all resources that are read (including those also written).
Sourcepub fn resource_writes(&self) -> &BTreeSet<ResourceId>
pub fn resource_writes(&self) -> &BTreeSet<ResourceId>
Returns all resources that are written.
Sourcepub fn resource_reads_only(&self) -> impl Iterator<Item = &ResourceId>
pub fn resource_reads_only(&self) -> impl Iterator<Item = &ResourceId>
Returns the set of read-only resources (read but not written).
Sourcepub fn resource_conflicts_with(&self, other: &Access) -> bool
pub fn resource_conflicts_with(&self, other: &Access) -> bool
Checks if resource access conflicts with another.
Two accesses conflict if one writes to a resource that the other reads or writes.
Sourcepub fn has_resource_access(&self) -> bool
pub fn has_resource_access(&self) -> bool
Checks if this access has any resource access.
Sourcepub fn has_component_access(&self) -> bool
pub fn has_component_access(&self) -> bool
Checks if this access has any component access.
Sourcepub fn add_non_send_read(&mut self, id: NonSendResourceId)
pub fn add_non_send_read(&mut self, id: NonSendResourceId)
Adds a read access for the given non-send resource.
Sourcepub fn add_non_send_write(&mut self, id: NonSendResourceId)
pub fn add_non_send_write(&mut self, id: NonSendResourceId)
Adds a write access for the given non-send resource.
Write access implies read access.
Sourcepub fn non_send_reads(&self) -> impl Iterator<Item = &NonSendResourceId>
pub fn non_send_reads(&self) -> impl Iterator<Item = &NonSendResourceId>
Returns all non-send resources that are read (including those also written).
Sourcepub fn non_send_writes(&self) -> &BTreeSet<NonSendResourceId>
pub fn non_send_writes(&self) -> &BTreeSet<NonSendResourceId>
Returns all non-send resources that are written.
Sourcepub fn non_send_reads_only(&self) -> impl Iterator<Item = &NonSendResourceId>
pub fn non_send_reads_only(&self) -> impl Iterator<Item = &NonSendResourceId>
Returns the set of read-only non-send resources (read but not written).
Sourcepub fn non_send_conflicts_with(&self, other: &Access) -> bool
pub fn non_send_conflicts_with(&self, other: &Access) -> bool
Checks if non-send resource access conflicts with another.
Two accesses conflict if one writes to a non-send resource that the other reads or writes.
Sourcepub fn has_non_send_access(&self) -> bool
pub fn has_non_send_access(&self) -> bool
Checks if this access has any non-send resource access.
Sourcepub fn requires_main_thread(&self) -> bool
pub fn requires_main_thread(&self) -> bool
Returns true if this access requires execution on the main thread.
This returns true if there is any non-send resource access.
Sourcepub fn get_conflicts(&self, other: &Access) -> Option<AccessConflict>
pub fn get_conflicts(&self, other: &Access) -> Option<AccessConflict>
Returns detailed information about conflicts between this access and another.
If there are no conflicts, returns None. Otherwise, returns an
AccessConflict describing all the conflicting components and resources.
§Example
use goud_engine::ecs::query::Access;
use goud_engine::ecs::component::ComponentId;
use goud_engine::ecs::Component;
#[derive(Clone, Copy)]
struct Position { x: f32, y: f32 }
impl Component for Position {}
let mut access1 = Access::new();
access1.add_write(ComponentId::of::<Position>());
let mut access2 = Access::new();
access2.add_read(ComponentId::of::<Position>());
let conflict = access1.get_conflicts(&access2);
assert!(conflict.is_some());
let conflict = conflict.unwrap();
assert_eq!(conflict.component_conflicts().len(), 1);Trait Implementations§
Auto Trait Implementations§
impl Freeze for Access
impl RefUnwindSafe for Access
impl Send for Access
impl Sync for Access
impl Unpin for Access
impl UnsafeUnpin for Access
impl UnwindSafe for Access
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().