Skip to content

Commit

Permalink
Minor tweaks in the clock module
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsuya6502 committed Jan 5, 2025
1 parent d22f4f3 commit 5d03e02
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/common/time/clock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,9 @@ impl Default for ClockType {
fn default() -> Self {
#[cfg(feature = "quanta")]
{
// Try to get the both origins at close to the same time. Assuming that
// `quanta::Instant::now` has lower latency than `StdInstant::now`.
let quanta_origin = quanta::Instant::now();
let std_origin = StdInstant::now();
return ClockType::Hybrid {
std_origin,
quanta_origin,
std_origin: StdInstant::now(),
quanta_origin: quanta::Instant::now(),
};
}

Expand Down Expand Up @@ -113,6 +109,9 @@ impl Clock {
}

/// Converts an `Instant` to a `std::time::Instant`.
///
/// **IMPORTANT**: The caller must ensure that the `Instant` was created by this
/// `Clock`, otherwise the resulting `std::time::Instant` will be incorrect.
pub(crate) fn to_std_instant(&self, instant: Instant) -> StdInstant {
match &self.ty {
ClockType::Standard { origin } => {
Expand Down

0 comments on commit 5d03e02

Please sign in to comment.