mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Use tokio to delay main loop, not thread::sleep
This commit is contained in:
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
and even out. Previously the bottom rows were always last to be written.
|
and even out. Previously the bottom rows were always last to be written.
|
||||||
- Add more examples: ball, comet, pulser.
|
- Add more examples: ball, comet, pulser.
|
||||||
- Refine the keyboard layout grid for GX502.
|
- Refine the keyboard layout grid for GX502.
|
||||||
|
- Use tokio to delay main loop, not thread::sleep
|
||||||
|
|
||||||
## [0.9.4] - 2020-05-05
|
## [0.9.4] - 2020-05-05
|
||||||
### Changed
|
### Changed
|
||||||
|
|||||||
@@ -175,11 +175,11 @@ pub async fn start_daemon() -> Result<(), Box<dyn Error>> {
|
|||||||
// Cool-down steps
|
// Cool-down steps
|
||||||
// This block is to prevent the loop spooling as fast as possible and saturating the CPU
|
// This block is to prevent the loop spooling as fast as possible and saturating the CPU
|
||||||
if now.duration_since(time_mark).as_millis() > 500 {
|
if now.duration_since(time_mark).as_millis() > 500 {
|
||||||
std::thread::sleep(Duration::from_millis(200));
|
tokio::time::delay_for(Duration::from_millis(200)).await;
|
||||||
} else if now.duration_since(time_mark).as_millis() > 100 {
|
} else if now.duration_since(time_mark).as_millis() > 100 {
|
||||||
std::thread::sleep(Duration::from_millis(50));
|
tokio::time::delay_for(Duration::from_millis(50)).await;
|
||||||
} else {
|
} else {
|
||||||
std::thread::sleep(Duration::from_micros(300));
|
tokio::time::delay_for(Duration::from_micros(300)).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user