pub trait System<'a> {
    type SystemData: SystemData<'a>;

    const NAME: &'static str;
    const PHASE: Phase;
    const ORIGIN: Origin;

    // Required method
    fn run(job: &mut Job<Self>, data: Self::SystemData);

    // Provided method
    fn sys_name() -> String { ... }
}
Expand description

This trait wraps around specs::System and does additional veloren tasks like metrics collection

use specs::Read;
pub use veloren_common_ecs::{Job, Origin, ParMode, Phase, System};
pub struct Sys;
impl<'a> System<'a> for Sys {
    type SystemData = (Read<'a, ()>, Read<'a, ()>);

    const NAME: &'static str = "example";
    const ORIGIN: Origin = Origin::Frontend("voxygen");
    const PHASE: Phase = Phase::Create;

    fn run(job: &mut Job<Self>, (_read, _read2): Self::SystemData) {
        std::thread::sleep(Duration::from_millis(100));
        job.cpu_stats.measure(ParMode::Rayon);
        std::thread::sleep(Duration::from_millis(500));
        job.cpu_stats.measure(ParMode::Single);
        std::thread::sleep(Duration::from_millis(40));
    }
}

Required Associated Types§

source

type SystemData: SystemData<'a>

Required Associated Constants§

source

const NAME: &'static str

source

const PHASE: Phase

source

const ORIGIN: Origin

Required Methods§

source

fn run(job: &mut Job<Self>, data: Self::SystemData)

Provided Methods§

Object Safety§

This trait is not object safe.

Implementors§