Documentation
use scoped_pool::Pool;

#[derive(Clone, Copy, Debug)]
pub struct BMConfig {
    runners: i32,
}

impl BMConfig {
    pub fn new(runners: i32) -> Self {
        Self { runners }
    }

    pub fn step(&self, runners: i32) -> Self {
        Self {
            runners: self.runners + runners,
        }
    }
}

pub fn bmexec(config: BMConfig, f: impl FnOnce() + Send + Clone) {
    let pool = Pool::new(config.runners as usize);

    pool.scoped(|scope| {
        for _ in 0..config.runners {
            scope.execute(f.clone());
        }
    });
}