pub unsafe trait System {
// Required methods
fn is_local(&self) -> bool;
fn world_access(&self) -> Option<Access>;
fn visit_archetype(&self, archetype: &Archetype) -> bool;
fn component_access(
&self,
archetype: &Archetype,
comp: &ComponentInfo,
) -> Option<Access>;
fn resource_type_access(&self, ty: TypeId) -> Option<Access>;
unsafe fn run_unchecked(
&mut self,
world: NonNull<World>,
queue: &mut dyn ActionBufferQueue,
);
// Provided methods
fn run(&mut self, world: &mut World, queue: &mut dyn ActionBufferQueue) { ... }
fn run_alone(&mut self, world: &mut World) { ... }
}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§
Sourcefn is_local(&self) -> bool
fn is_local(&self) -> bool
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 systems will return some Access::Read, and few will return none.
Sourcefn visit_archetype(&self, archetype: &Archetype) -> bool
fn visit_archetype(&self, archetype: &Archetype) -> bool
Checks if any query of this system will visit specified archetype.
Sourcefn component_access(
&self,
archetype: &Archetype,
comp: &ComponentInfo,
) -> Option<Access>
fn component_access( &self, archetype: &Archetype, comp: &ComponentInfo, ) -> Option<Access>
Returns access type to the specified component type this system may perform.
Sourcefn resource_type_access(&self, ty: TypeId) -> Option<Access>
fn resource_type_access(&self, ty: 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 ActionBufferQueue,
)
unsafe fn run_unchecked( &mut self, world: NonNull<World>, queue: &mut dyn ActionBufferQueue, )
Runs the system with given context instance.
If is_local() returns true then running it outside local thread is unsound.
Provided Methods§
Sourcefn run(&mut self, world: &mut World, queue: &mut dyn ActionBufferQueue)
fn run(&mut self, world: &mut World, queue: &mut dyn ActionBufferQueue)
Runs the system with exclusive access to World.