mirror of
https://github.com/Xevion/Pac-Man.git
synced 2025-12-14 20:12:24 -06:00
feat: avoid using spin sleep unless focused
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user