()
| 16 | } |
| 17 | |
| 18 | fn main() { |
| 19 | env_logger::init(); |
| 20 | let args = Args::parse(); |
| 21 | |
| 22 | if args.num_threads < 1 { |
| 23 | eprintln!("Invalid number of threads"); |
| 24 | return; |
| 25 | } |
| 26 | |
| 27 | let mut threads = Vec::with_capacity(args.num_threads); |
| 28 | let _ = std::fs::remove_file("basic_mapping"); |
| 29 | let max = args.count_to; |
| 30 | // Spawn N threads |
| 31 | for i in 0..args.num_threads { |
| 32 | let thread_id = i + 1; |
| 33 | threads.push(thread::spawn(move || { |
| 34 | increment_value("basic_mapping", thread_id, max); |
| 35 | })); |
| 36 | } |
| 37 | |
| 38 | // Wait for threads to exit |
| 39 | for t in threads.drain(..) { |
| 40 | t.join().unwrap(); |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | /// Increments a value that lives in shared memory |
| 45 | fn increment_value(shmem_flink: &str, thread_num: usize, max: u8) { |
nothing calls this directly
no test coverage detected