This commit is contained in:
osukhoroslov committed 2026-10-03 11:42:32 +03:00
1 parent 6008cff9f6
commit 209c66683d
15 files changed
+5061 -3

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
use serde::Serialize;
use sugars::boxed;
use anysystem::python::PyProcessFactory;
use anysystem::System;
#[derive(Copy, Clone)]
pub struct TestConfig<'a> {
pub proc_factory: &'a PyProcessFactory,
pub proc_count: u64,
pub seed: u64,
pub monkeys: u32,
pub debug: bool,
}
#[derive(Serialize)]
pub struct BroadcastMessage<'a> {
pub text: &'a str,
}
pub fn build_system(config: &TestConfig) -> System {
let mut sys = System::new(config.seed);
let mut proc_names = Vec::new();
for n in 0..config.proc_count {
proc_names.push(format!("{n}"));
}
for proc_name in &proc_names {
let proc = config
.proc_factory
.build((proc_name, proc_names.clone()), config.seed);
// process and node on which it runs have the same name
sys.add_node(proc_name);
sys.add_process(proc_name, boxed!(proc), proc_name);
}
sys
}