pub unsafe trait System {
fn is_local(&self) -> bool;
fn world_access(&self) -> Option<Access>;
fn skips_archetype(&self, archetype: &Archetype) -> bool;
fn access_component(&self, id: TypeId) -> Option<Access>;
fn access_resource(&self, id: TypeId) -> Option<Access>;
unsafe fn run_unchecked(
&mut self,
world: NonNull<World>,
queue: &mut dyn ActionQueue
);
}Expand description
System that can run using reference to World.
System::is_local method returns true for local systems.
Such system may be run only on thread where World lives.
System::run_unchecked call is unsafe:
- running local system outside local thread may cause undefined behavior.
- running system for which
System::world_accessreturns [Some(Access::Write)] in parallel with system for whichSystem::world_accessreturns [Some(_)] may cause undefined behavior.
Safety
If System::is_local() returns false System::run_unchecked must be safe to call from any thread.
Otherwise System::run_unchecked must be safe to call from local thread.
System::run_unchecked must be safe to call in parallel with any system if System::world_access returns None.
System::run_unchecked must be safe to call in parallel with other systems if for all of them System::world_access returns [Some(Access::Read)].
Required Methods
Returns true for local systems that can be run only on thread where World lives.
sourcefn world_access(&self) -> Option<Access>
fn world_access(&self) -> Option<Access>
Returns access type performed on the entire World.
Most arguments will return some Access::Read, and few will return none.
sourcefn skips_archetype(&self, archetype: &Archetype) -> bool
fn skips_archetype(&self, archetype: &Archetype) -> bool
Checks if all queries from this system will skip specified archetype.
sourcefn access_component(&self, id: TypeId) -> Option<Access>
fn access_component(&self, id: TypeId) -> Option<Access>
Returns access type to the specified component type this system may perform.
sourcefn access_resource(&self, id: TypeId) -> Option<Access>
fn access_resource(&self, id: TypeId) -> Option<Access>
Returns access type to the specified resource type this system may perform.
sourceunsafe fn run_unchecked(
&mut self,
world: NonNull<World>,
queue: &mut dyn ActionQueue
)
unsafe fn run_unchecked(
&mut self,
world: NonNull<World>,
queue: &mut dyn ActionQueue
)
Runs the system with given context instance.
If is_local() returns true then running it outside local thread is unsound.