Struct djinn::Manager
[−]
[src]
pub struct Manager<S: Simulation, C: Redis> { pub population: Population<S, C>, // some fields omitted }
Manages a simulation and coordinates a set of workers.
Fields
population: Population<S, C>
Methods
impl<S: Simulation, C: Redis> Manager<S, C>
[src]
fn new(addr: &str, conn: C, simulation: S) -> Manager<S, C>
fn reset(&self)
Reset the manager. This unregisters all workers and queues.
fn run(&self, simulation: S, world: S::World, n_steps: usize)
Run the simulation for n_steps
.
This will spawn the population across available workers
and begin sending them synchronized commands to step through the simulation.
fn register_reporter<F>(&mut self, n_steps: usize, func: F) where
F: Fn(usize, &Population<S, C>, &Connection) -> () + Send + 'static,
F: Fn(usize, &Population<S, C>, &Connection) -> () + Send + 'static,
Register a reporter function to be called every n_steps
.
It receives a Population
which can be used to query agents,
compute aggregate statistics, etc, and a Redis connection
that can be used, for example, to send reports via pubsub.
fn spawn(&mut self, state: S::State) -> u64
Spawn an agent.
fn spawns(&mut self, states: Vec<S::State>) -> Vec<u64>
Spawn multiple agents.
fn n_workers(&self) -> usize
Get the number of workers.