-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add spin_sleep_util crate * Deprecate LoopHelper
- Loading branch information
1 parent
0bac1b5
commit dcd48ef
Showing
11 changed files
with
528 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
[package] | ||
name = "spin_sleep" | ||
version = "1.1.1" | ||
authors = ["Alex Butler <[email protected]>"] | ||
edition = "2021" | ||
authors = ["Alex Butler <[email protected]>"] | ||
description = "Accurate sleeping. Only use native sleep as far as it can be trusted, then spin." | ||
repository = "https://github.com/alexheretic/spin-sleep" | ||
keywords = ["sleep"] | ||
license = "Apache-2.0" | ||
readme="README.md" | ||
readme = "README.md" | ||
|
||
[target.'cfg(windows)'.dependencies] | ||
windows-sys = { version = "0.52", features = [ | ||
"Win32_Foundation", "Win32_Security", "Win32_System", "Win32_System_Threading", "Win32_Media" | ||
"Win32_Foundation", | ||
"Win32_Security", | ||
"Win32_System", | ||
"Win32_System_Threading", | ||
"Win32_Media", | ||
] } | ||
|
||
[dev-dependencies] | ||
|
@@ -20,3 +24,6 @@ approx = "0.5" | |
[features] | ||
# Controls certain tests that are not deterministic | ||
nondeterministic_tests = [] | ||
|
||
[workspace] | ||
members = ["util"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# v0.1.0 | ||
* Add `Interval`, `RateReporter`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[package] | ||
name = "spin_sleep_util" | ||
version = "0.1.0" | ||
edition = "2021" | ||
authors = ["Alex Butler <[email protected]>"] | ||
description = "Utils using spin_sleep" | ||
repository = "https://github.com/alexheretic/spin-sleep" | ||
keywords = ["sleep", "loop", "interval"] | ||
license = "Apache-2.0" | ||
readme = "README.md" | ||
|
||
[dependencies] | ||
spin_sleep = { path = "..", version = "1" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
spin_sleep_util | ||
[![crates.io](https://img.shields.io/crates/v/spin_sleep_util.svg)](https://crates.io/crates/spin_sleep_util) | ||
[![Documentation](https://docs.rs/spin_sleep_util/badge.svg)](https://docs.rs/spin_sleep_util) | ||
=============== | ||
Utils using spin_sleep. | ||
|
||
## Example: Frame limiter | ||
`Interval` may be used to limit a loop to a max fps by calling `Interval::tick` at the start or end of each loop. | ||
|
||
```rust | ||
// Create an interval to tick 144 times each second | ||
let mut interval = spin_sleep_util::interval(Duration::from_secs(1) / 144); | ||
loop { | ||
compute_something(); // do loop work | ||
|
||
// tick: sleep using a SpinSleeper until next tick. | ||
// The default `Skip` missed ticke behaviour is appropriate for a frame limiter | ||
interval.tick(); | ||
} | ||
``` |
Oops, something went wrong.