diff --git a/crates/coremem/src/driver.rs b/crates/coremem/src/driver.rs index 234f25e..381012c 100644 --- a/crates/coremem/src/driver.rs +++ b/crates/coremem/src/driver.rs @@ -28,7 +28,7 @@ pub struct Driver { time_spent_prepping_render: Duration, time_spent_blocked_on_render: Duration, time_spent_rendering: Arc>, - measurements: Vec>, + measurements: Vec>, stimuli: StimuliAdapter, start_time: Instant, last_diag_time: Instant, @@ -49,10 +49,10 @@ impl Driver { time_spent_blocked_on_render: Default::default(), time_spent_rendering: Default::default(), measurements: vec![ - Box::new(meas::Time), - Box::new(meas::Meta), - Box::new(meas::Energy::world()), - Box::new(meas::Power::world()), + Arc::new(meas::Time), + Arc::new(meas::Meta), + Arc::new(meas::Energy::world()), + Arc::new(meas::Power::world()), ], stimuli: StimuliAdapter::new(), start_time: Instant::now(), @@ -66,7 +66,7 @@ impl Driver { } pub fn add_measurement(&mut self, m: Meas) { - self.measurements.push(Box::new(m)); + self.measurements.push(Arc::new(m)); } pub fn set_steps_per_stim(&mut self, steps_per_stim: u64) { diff --git a/crates/coremem/src/meas.rs b/crates/coremem/src/meas.rs index 2facc3c..4ef9102 100644 --- a/crates/coremem/src/meas.rs +++ b/crates/coremem/src/meas.rs @@ -2,17 +2,13 @@ use crate::geom::{Meters, Region, Torus, WorldRegion}; use crate::real::{Real as _, ToFloat as _}; use crate::cross::vec::Vec3; use crate::sim::GenericSim; -use dyn_clone::{self, DynClone}; use indexmap::IndexMap; use serde::{Serialize, Deserialize}; -// TODO: remove this Clone and Send requirement? Have Measurements be shared by-reference across -// threads? i.e. Sync, and no Clone -pub trait AbstractMeasurement: Send + Sync + DynClone { +pub trait AbstractMeasurement: Send + Sync { fn eval(&self, state: &dyn GenericSim) -> String; fn key_value(&self, state: &dyn GenericSim) -> IndexMap; } -dyn_clone::clone_trait_object!(AbstractMeasurement); /// create one IndexMap out of several measurements pub fn eval_multiple_kv(state: &dyn GenericSim, meas: &[&dyn AbstractMeasurement]) -> IndexMap {