diff options
author | Clement Tsang <34804052+ClementTsang@users.noreply.github.com> | 2023-04-15 00:15:36 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-15 00:15:36 -0400 |
commit | 20902e87b97091bf7d524cdec42a87bd8e145d74 (patch) | |
tree | 539263f29e363ecb9808fadbf110a5451c42dded /src/app | |
parent | fa1f4976e25b3ac790a95c0ec8d92a76517f8daf (diff) |
other: Speed up first draw and first data collection (#1100)
* other: add first draw immediately after initialization
Previously, I would only do the first draw after an event triggered, so
this just makes it so that I *always* draw once first. Some widgets look
a bit weird with no data, but this is fine I guess if we want to gain a
bit of responsiveness.
* other: potentially shorten first time to get data
* other: move event loop thread init earlier in app initialization
Diffstat (limited to 'src/app')
-rw-r--r-- | src/app/data_harvester.rs | 15 | ||||
-rw-r--r-- | src/app/layout_manager.rs | 2 |
2 files changed, 15 insertions, 2 deletions
diff --git a/src/app/data_harvester.rs b/src/app/data_harvester.rs index 67ff1e5b..362b7251 100644 --- a/src/app/data_harvester.rs +++ b/src/app/data_harvester.rs @@ -194,7 +194,20 @@ impl DataCollector { self.update_data(); - std::thread::sleep(std::time::Duration::from_millis(250)); + // Sleep a few seconds to avoid potentially weird data... + let sleep_duration = { + cfg_if::cfg_if! { + if #[cfg(target_os = "freebsd")] { + // FreeBSD's min duration value is 1s, which is a bit too long for me so I'll accept the one-time + // inaccuracy. + std::time::Duration::from_millis(250) + } else { + sysinfo::System::MINIMUM_CPU_UPDATE_INTERVAL + Duration::from_millis(1) + } + } + }; + + std::thread::sleep(sleep_duration); self.data.cleanup(); } diff --git a/src/app/layout_manager.rs b/src/app/layout_manager.rs index 032ccf98..137a9b12 100644 --- a/src/app/layout_manager.rs +++ b/src/app/layout_manager.rs @@ -993,7 +993,7 @@ Supported widget names: } } -#[derive(Clone, Default, Debug)] +#[derive(Clone, Default, Debug, Copy)] pub struct UsedWidgets { pub use_cpu: bool, pub use_mem: bool, |