()
| 18 | } |
| 19 | |
| 20 | fn main() { |
| 21 | env_logger::init(); |
| 22 | let args = Args::parse(); |
| 23 | |
| 24 | if args.num_threads < 1 { |
| 25 | eprintln!("num_threads should be 2 or more"); |
| 26 | return; |
| 27 | } |
| 28 | let mut threads = Vec::with_capacity(args.num_threads); |
| 29 | let _ = std::fs::remove_file("mutex_mapping"); |
| 30 | |
| 31 | // Spawn N threads |
| 32 | for i in 0..args.num_threads { |
| 33 | let thread_id = i + 1; |
| 34 | threads.push(thread::spawn(move || { |
| 35 | increment_value("mutex_mapping", thread_id); |
| 36 | })); |
| 37 | } |
| 38 | |
| 39 | // Wait for threads to exit |
| 40 | for t in threads.drain(..) { |
| 41 | t.join().unwrap(); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | fn increment_value(shmem_flink: &str, thread_num: usize) { |
| 46 | // Create or open the shared memory mapping |
nothing calls this directly
no test coverage detected