MCPcopy Create free account
hub / github.com/elast0ny/shared_memory / main

Function main

examples/basic.rs:18–42  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16}
17
18fn 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
45fn increment_value(shmem_flink: &str, thread_num: usize, max: u8) {

Callers

nothing calls this directly

Calls 1

increment_valueFunction · 0.70

Tested by

no test coverage detected