feat: avoid using spin sleep unless focused

This commit is contained in:
2025-08-13 21:36:06 -05:00
parent d80d7061e7
commit 12a63374a8
5 changed files with 22 additions and 18 deletions

View File

@@ -11,8 +11,12 @@ use crate::platform::Platform;
pub struct DesktopPlatform;
impl Platform for DesktopPlatform {
fn sleep(&self, duration: Duration) {
spin_sleep::sleep(duration);
fn sleep(&self, duration: Duration, focused: bool) {
if focused {
spin_sleep::sleep(duration);
} else {
std::thread::sleep(duration);
}
}
fn get_time(&self) -> f64 {