|
1 | | -use std::sync::Mutex; |
2 | | -use sysinfo::System; |
| 1 | +// use std::sync::Mutex; |
| 2 | +// use sysinfo::System; |
3 | 3 |
|
4 | | -static CHECK_NEW_INSTANCE_AND_CLOSE: Mutex<bool> = Mutex::new(false); |
| 4 | +// static CHECK_NEW_INSTANCE_AND_CLOSE: Mutex<bool> = Mutex::new(false); |
5 | 5 |
|
6 | 6 | pub fn check_for_new_instance_and_close() { |
7 | | - let mut var = CHECK_NEW_INSTANCE_AND_CLOSE.lock().unwrap(); |
8 | | - *var = true; |
| 7 | + // let mut var = CHECK_NEW_INSTANCE_AND_CLOSE.lock().unwrap(); |
| 8 | + // *var = true; |
9 | 9 | } |
10 | 10 |
|
11 | 11 | pub fn initialize_background_thread() { |
12 | | - std::thread::spawn(move || loop { |
13 | | - let mut new_instance_check = CHECK_NEW_INSTANCE_AND_CLOSE.lock().unwrap(); |
14 | | - if *new_instance_check { |
15 | | - let timeout_since_start = std::time::Duration::from_secs(10); |
16 | | - let now: std::time::Instant = std::time::Instant::now(); |
17 | | - let elapsed = now.elapsed(); |
18 | | - if elapsed > timeout_since_start { |
19 | | - *new_instance_check = false; |
20 | | - } |
| 12 | + // std::thread::spawn(move || loop { |
| 13 | + // let mut new_instance_check = CHECK_NEW_INSTANCE_AND_CLOSE.lock().unwrap(); |
| 14 | + // if *new_instance_check { |
| 15 | + // let timeout_since_start = std::time::Duration::from_secs(10); |
| 16 | + // let now: std::time::Instant = std::time::Instant::now(); |
| 17 | + // let elapsed = now.elapsed(); |
| 18 | + // if elapsed > timeout_since_start { |
| 19 | + // *new_instance_check = false; |
| 20 | + // } |
21 | 21 |
|
22 | | - let s = System::new_all(); |
| 22 | + // let s = System::new_all(); |
23 | 23 |
|
24 | | - let current_process = s.process(sysinfo::get_current_pid().unwrap()).unwrap(); |
25 | | - for process in s.processes_by_exact_name("omp-launcher.exe") { |
26 | | - if process.pid() != current_process.pid() { |
27 | | - let new_uptime = process.run_time(); |
28 | | - let current_uptime = current_process.run_time(); |
29 | | - if new_uptime < current_uptime { |
30 | | - current_process.kill(); |
31 | | - *new_instance_check = false; |
32 | | - } |
33 | | - } |
34 | | - } |
35 | | - } |
| 24 | + // let current_process = s.process(sysinfo::get_current_pid().unwrap()).unwrap(); |
| 25 | + // for process in s.processes_by_exact_name("omp-launcher.exe") { |
| 26 | + // if process.pid() != current_process.pid() { |
| 27 | + // let new_uptime = process.run_time(); |
| 28 | + // let current_uptime = current_process.run_time(); |
| 29 | + // if new_uptime < current_uptime { |
| 30 | + // current_process.kill(); |
| 31 | + // *new_instance_check = false; |
| 32 | + // } |
| 33 | + // } |
| 34 | + // } |
| 35 | + // } |
36 | 36 |
|
37 | | - std::thread::sleep(std::time::Duration::from_millis(500)); |
38 | | - }); |
| 37 | + // std::thread::sleep(std::time::Duration::from_millis(500)); |
| 38 | + // }); |
39 | 39 | } |
0 commit comments