-
Notifications
You must be signed in to change notification settings - Fork 200
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
Need for a Generic Instant/Time/Duration #122
Comments
I'm curious what you mean by Its definition is In my application, I'm using the time since a stable reference point (e.g. power on or the unix epoch) for time-keeping purposes. /// Something which records the elapsed real time.
///
/// This uses shared references because it may be shared between multiple
/// components at any one time.
pub trait SystemClock {
/// The amount of time that has passed since a clock-specific reference
/// point (e.g. device startup or the unix epoch).
fn elapsed(&self) -> Duration;
} |
First of all, thanks for sharing your application repo! May I ask how I could implement such 'time-measuring' functionality without |
On an embedded device (most This is typically implemented by registering a If you're compiling with the full standard library we know we'll always have access to the "current time" via the OS, so I've provided an implementation instead of forcing every user to write it themselves. |
Hi All,
I'v run into the need for a generic "Instant" implementation several times.
Depending on your application you can decide what resolution ticks you need (and how often you can tolerate an overflow) and what kind of HW resources you have to increase a counter.
Then this implementation of "Instant" trait(s) could be passed to various stuff, like:
Each of these implementations would be generic about the "Instant" trait(s), but all of them likely
The std time, duration is too big overhead for an embedded system, with this abstraction each application could be provided with a well optimized time measurement utility.
Please comment!
The text was updated successfully, but these errors were encountered: