-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add mock for timers #40
Conversation
I think embedded_time needs a newer rust version. They don't have a MSRV given, so we need to figure that out somehow. Edit: 1.51 seems to be right. It is now possible to also set the MSRV as package attribute in Cargo.toml since rust 1.56. This will generate a warning in versions < 1.56, but will not fail, see here. |
Sorry for the long delay. I'm quite busy at the moment (as always 😂), so if someone else with timer experience would do a first review, that would already be helpful. (Anyone can do a review, not just maintainers 🙂) The branch also needs a rebase. |
In the mean time we have decided to remove timers in |
@niclashoyer would you be interested in doing the backport suggested by @eldruin? |
d98e756
to
85cb29b
Compare
Sorry for the long delay again. I rebased your branch against current master and will now review the contribution 🙂 Regarding the added dependencies, I'm thinking about putting the timer feature behind a cargo flag. |
I pushed two changes:
Thanks! 👍🏻 |
This is required to be able to use dep: syntax in Cargo.toml
Added a mock for timers using embedded-time with nanosecond precision. A single clock can be used to create multiple timers. The clock can be freely skipped by any time value supported by embedded_time (e.g. microseconds, seconds, nanoseconds, …).
To support sharing a clock and timer between threads I relied on
Arc<AtomicU64>
for the time base. That also allows each timer to actually own the clock, so that they can be freely shared with any driver implementation.I added this on top of #39. If wanted, I could also try to backport this.