Competition – calling out to pMARS

It's now time to consider how each Individual competes. Earlier, we discussed calling out to pmars on-system, which requires on-disk representations of the two competing Individual warriors. True to that, competition first serializes both warriors to temporary locations on the disk:

    pub fn compete(&self, other: &Individual) -> Winner {
        let dir = TempDir::new("simulate")                      .expect("could not make tempdir");

        let l_path = dir.path().join("left.red");
        let mut lfp = BufWriter::new(File::create(&l_path)                          .expect("could not write lfp"));
        self.serialize(&mut lfp).expect("could not serialize");
        drop(lfp);

        let r_path = dir.path().join("right.red");
        let mut rfp = BufWriter::new(File::create(&r_path) .expect("could not ...

Get Hands-On Concurrency with Rust now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.