From 0af34e9e01cf07d5da0bda81c59709bc3c1cb701 Mon Sep 17 00:00:00 2001 From: Javed Nissar <1396351+RestitutorOrbis@users.noreply.github.com> Date: Sat, 9 May 2020 21:32:42 -0400 Subject: [PATCH] Resolve #50 by parallelizing raw->map jobs using std::thread (#55) --- importer/src/main.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/importer/src/main.rs b/importer/src/main.rs index b9e5a54b82..029e9af040 100644 --- a/importer/src/main.rs +++ b/importer/src/main.rs @@ -4,6 +4,7 @@ mod los_angeles; mod seattle; mod soundcast; mod utils; +use std::thread; struct Job { city: String, @@ -51,6 +52,7 @@ fn main() { abstutil::list_all_objects(format!("../data/input/{}/polygons", job.city)) }; + let mut handles = vec![]; for name in names { if job.osm_to_raw { match job.city.as_ref() { @@ -63,7 +65,13 @@ fn main() { } if job.raw_to_map { - utils::raw_to_map(&name, job.use_fixes); + let thread_name = name.clone(); + //Fetch use_fixes after already loading into job in order to avoid move compile error + let use_fixes = job.use_fixes; + let handle = thread::spawn(move || { + utils::raw_to_map(&thread_name, use_fixes); + }); + handles.push(handle); } if job.scenario { @@ -84,4 +92,7 @@ fn main() { soundcast::make_weekday_scenario_with_everyone(&map, &mut timer).save(); } } + for handle in handles { + handle.join().unwrap(); + } }