Specs - Parallel ECS
Under Other
By amethyst

rust ecs parallel-ecs


Specs Parallel ECS

[]dl []cov

Specs is an Entity-Component System written in Rust.
Unlike most other ECS libraries out there, it provides

Minimum Rust version: 1.40

Link to the book

use specs::prelude::*;

// A component contains data
// which is associated with an entity.


struct Vel(f32);

impl Component for Vel {
type Storage = VecStorage;


struct Pos(f32);

impl Component for Pos {
type Storage = VecStorage;

struct SysA;

impl<'a> System<'a> for SysA {
// These are the resources required for execution.
// You can also define a struct and #[derive(SystemData)],
// see the full example.
type SystemData = (WriteStorage<'a, Pos>, ReadStorage<'a, Vel>);

fn run(&mut self, (mut pos, vel): Self::SystemData) {
// The `.join()` combines multiple component storages,
// so we get access to all entities which have
// both a position and a velocity.
for (pos, vel) in (&mut pos, &vel).join() {
pos.0 += vel.0;


fn main() {
// The World is our
// container for components
// and other resources.
let mut world = World::new();

// An entity may or may not contain some component.


// This entity does not have `Vel`, so it won't be dispatched.

// This builds a dispatcher.
// The third parameter of `with` specifies
// logical dependencies on other systems.
// Since we only have one, we don't depend on anything.
// See the `full` example for dependencies.
let mut dispatcher = DispatcherBuilder::new().with(SysA, "sys_a", &[]).build();
// This will call the `setup` function of every system.
// In this example this has no effect since we already registered our components.
dispatcher.setup(&mut world);

// This dispatches all the systems in parallel (but blocking).
dispatcher.dispatch(&mut world);


Please look into the examples directory for more.

Public dependencies

| crate | version |
| hibitset | |
| rayon | |
| shred | |
| shrev | |


Contribution is very welcome! If you didn't contribute before,
just filter for issues with "easy" or "good first issue" label.
Please note that your contributions are assumed to be dual-licensed under Apache-2.0/MIT.