mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2024-11-16 15:27:46 +00:00
fix: remove arc mutex overhead and update gui ticks
This commit is contained in:
parent
1617882f29
commit
783b3148c7
1 changed files with 67 additions and 67 deletions
|
@ -491,15 +491,15 @@ impl Helper {
|
||||||
|
|
||||||
// 4. Loop as watchdog
|
// 4. Loop as watchdog
|
||||||
let mut first_loop = true;
|
let mut first_loop = true;
|
||||||
let mut last_p2pool_request = Arc::new(Mutex::new(tokio::time::Instant::now()));
|
let mut last_p2pool_request = tokio::time::Instant::now();
|
||||||
let mut last_status_request = Arc::new(Mutex::new(tokio::time::Instant::now()));
|
let mut last_status_request = tokio::time::Instant::now();
|
||||||
|
|
||||||
info!("P2Pool | Entering watchdog mode... woof!");
|
info!("P2Pool | Entering watchdog mode... woof!");
|
||||||
loop {
|
loop {
|
||||||
// Set timer
|
// Set timer
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
debug!("P2Pool Watchdog | ----------- Start of loop -----------");
|
debug!("P2Pool Watchdog | ----------- Start of loop -----------");
|
||||||
lock!(gui_api).tick = (lock!(last_p2pool_request).elapsed().as_secs() % 60) as u8;
|
lock!(gui_api).tick = (last_p2pool_request.elapsed().as_secs() % 60) as u8;
|
||||||
|
|
||||||
// Check if the process is secretly died without us knowing :)
|
// Check if the process is secretly died without us knowing :)
|
||||||
if check_died(
|
if check_died(
|
||||||
|
@ -544,7 +544,7 @@ impl Helper {
|
||||||
}
|
}
|
||||||
// If more than 1 minute has passed, read the other API files.
|
// If more than 1 minute has passed, read the other API files.
|
||||||
let last_p2pool_request_expired =
|
let last_p2pool_request_expired =
|
||||||
lock!(last_p2pool_request).elapsed() >= Duration::from_secs(60);
|
last_p2pool_request.elapsed() >= Duration::from_secs(60);
|
||||||
|
|
||||||
if last_p2pool_request_expired {
|
if last_p2pool_request_expired {
|
||||||
debug!("P2Pool Watchdog | Attempting [network] & [pool] API file read");
|
debug!("P2Pool Watchdog | Attempting [network] & [pool] API file read");
|
||||||
|
@ -557,13 +557,13 @@ impl Helper {
|
||||||
PrivP2poolPoolApi::from_str(&pool_api),
|
PrivP2poolPoolApi::from_str(&pool_api),
|
||||||
) {
|
) {
|
||||||
PubP2poolApi::update_from_network_pool(&pub_api, network_api, pool_api);
|
PubP2poolApi::update_from_network_pool(&pub_api, network_api, pool_api);
|
||||||
last_p2pool_request = Arc::new(Mutex::new(tokio::time::Instant::now()));
|
last_p2pool_request = tokio::time::Instant::now();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let last_status_request_expired =
|
let last_status_request_expired =
|
||||||
lock!(last_status_request).elapsed() >= Duration::from_secs(60);
|
last_status_request.elapsed() >= Duration::from_secs(60);
|
||||||
|
|
||||||
if (last_status_request_expired || first_loop)
|
if (last_status_request_expired || first_loop)
|
||||||
&& lock!(process).state == ProcessState::Alive
|
&& lock!(process).state == ProcessState::Alive
|
||||||
|
@ -581,7 +581,7 @@ impl Helper {
|
||||||
if let Err(e) = stdin.flush() {
|
if let Err(e) = stdin.flush() {
|
||||||
error!("P2Pool Watchdog | STDIN flush error: {}", e);
|
error!("P2Pool Watchdog | STDIN flush error: {}", e);
|
||||||
}
|
}
|
||||||
last_status_request = Arc::new(Mutex::new(tokio::time::Instant::now()));
|
last_status_request = tokio::time::Instant::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sleep (only if 900ms hasn't passed)
|
// Sleep (only if 900ms hasn't passed)
|
||||||
|
@ -997,66 +997,66 @@ impl PubP2poolApi {
|
||||||
// let blanks = " ".repeat(60 - (self.tick - 1));
|
// let blanks = " ".repeat(60 - (self.tick - 1));
|
||||||
// [use crate::PubP2poolApi;use crate::PubP2poolApi;"[", &stars, &blanks, "]"].concat().as_str()
|
// [use crate::PubP2poolApi;use crate::PubP2poolApi;"[", &stars, &blanks, "]"].concat().as_str()
|
||||||
match self.tick {
|
match self.tick {
|
||||||
1 => "[ ]",
|
0 => "[ ]",
|
||||||
2 => "[* ]",
|
1 => "[* ]",
|
||||||
3 => "[** ]",
|
2 => "[** ]",
|
||||||
4 => "[*** ]",
|
3 => "[*** ]",
|
||||||
5 => "[**** ]",
|
4 => "[**** ]",
|
||||||
6 => "[***** ]",
|
5 => "[***** ]",
|
||||||
7 => "[****** ]",
|
6 => "[****** ]",
|
||||||
8 => "[******* ]",
|
7 => "[******* ]",
|
||||||
9 => "[******** ]",
|
8 => "[******** ]",
|
||||||
10 => "[********* ]",
|
9 => "[********* ]",
|
||||||
11 => "[********** ]",
|
10 => "[********** ]",
|
||||||
12 => "[*********** ]",
|
11 => "[*********** ]",
|
||||||
13 => "[************ ]",
|
12 => "[************ ]",
|
||||||
14 => "[************* ]",
|
13 => "[************* ]",
|
||||||
15 => "[************** ]",
|
14 => "[************** ]",
|
||||||
16 => "[*************** ]",
|
15 => "[*************** ]",
|
||||||
17 => "[**************** ]",
|
16 => "[**************** ]",
|
||||||
18 => "[***************** ]",
|
17 => "[***************** ]",
|
||||||
19 => "[****************** ]",
|
18 => "[****************** ]",
|
||||||
20 => "[******************* ]",
|
19 => "[******************* ]",
|
||||||
21 => "[******************** ]",
|
20 => "[******************** ]",
|
||||||
22 => "[********************* ]",
|
21 => "[********************* ]",
|
||||||
23 => "[********************** ]",
|
22 => "[********************** ]",
|
||||||
24 => "[*********************** ]",
|
23 => "[*********************** ]",
|
||||||
25 => "[************************ ]",
|
24 => "[************************ ]",
|
||||||
26 => "[************************* ]",
|
25 => "[************************* ]",
|
||||||
27 => "[************************** ]",
|
26 => "[************************** ]",
|
||||||
28 => "[*************************** ]",
|
27 => "[*************************** ]",
|
||||||
29 => "[**************************** ]",
|
28 => "[**************************** ]",
|
||||||
30 => "[***************************** ]",
|
29 => "[***************************** ]",
|
||||||
31 => "[****************************** ]",
|
30 => "[****************************** ]",
|
||||||
32 => "[******************************* ]",
|
31 => "[******************************* ]",
|
||||||
33 => "[******************************** ]",
|
32 => "[******************************** ]",
|
||||||
34 => "[********************************* ]",
|
33 => "[********************************* ]",
|
||||||
35 => "[********************************** ]",
|
34 => "[********************************** ]",
|
||||||
36 => "[*********************************** ]",
|
35 => "[*********************************** ]",
|
||||||
37 => "[************************************ ]",
|
36 => "[************************************ ]",
|
||||||
38 => "[************************************* ]",
|
37 => "[************************************* ]",
|
||||||
39 => "[************************************** ]",
|
38 => "[************************************** ]",
|
||||||
40 => "[*************************************** ]",
|
39 => "[*************************************** ]",
|
||||||
41 => "[**************************************** ]",
|
40 => "[**************************************** ]",
|
||||||
42 => "[***************************************** ]",
|
41 => "[***************************************** ]",
|
||||||
43 => "[****************************************** ]",
|
42 => "[****************************************** ]",
|
||||||
44 => "[******************************************* ]",
|
43 => "[******************************************* ]",
|
||||||
45 => "[******************************************** ]",
|
44 => "[******************************************** ]",
|
||||||
46 => "[********************************************* ]",
|
45 => "[********************************************* ]",
|
||||||
47 => "[********************************************** ]",
|
46 => "[********************************************** ]",
|
||||||
48 => "[*********************************************** ]",
|
47 => "[*********************************************** ]",
|
||||||
49 => "[************************************************ ]",
|
48 => "[************************************************ ]",
|
||||||
50 => "[************************************************* ]",
|
49 => "[************************************************* ]",
|
||||||
51 => "[************************************************** ]",
|
50 => "[************************************************** ]",
|
||||||
52 => "[*************************************************** ]",
|
51 => "[*************************************************** ]",
|
||||||
53 => "[**************************************************** ]",
|
52 => "[**************************************************** ]",
|
||||||
54 => "[***************************************************** ]",
|
53 => "[***************************************************** ]",
|
||||||
55 => "[****************************************************** ]",
|
54 => "[****************************************************** ]",
|
||||||
56 => "[******************************************************* ]",
|
55 => "[******************************************************* ]",
|
||||||
57 => "[******************************************************** ]",
|
56 => "[******************************************************** ]",
|
||||||
58 => "[********************************************************* ]",
|
57 => "[********************************************************* ]",
|
||||||
59 => "[********************************************************** ]",
|
58 => "[********************************************************** ]",
|
||||||
60 => "[*********************************************************** ]",
|
59 => "[*********************************************************** ]",
|
||||||
_ => "[************************************************************]",
|
_ => "[************************************************************]",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue