]> git.lizzy.rs Git - rust.git/commitdiff
address review comments
authorChristian Poveda <git@pvdrz.com>
Mon, 12 Sep 2022 21:32:09 +0000 (16:32 -0500)
committerChristian Poveda <git@pvdrz.com>
Tue, 13 Sep 2022 20:16:41 +0000 (15:16 -0500)
src/clock.rs
src/shims/time.rs
tests/pass/shims/time-with-isolation.rs

index 4fab2b2c5f38bf177ff1a43c74f583fcd9a3eaf1..3f33273e1e541d577409d58e6fd756da531580bc 100644 (file)
@@ -1,13 +1,9 @@
-use std::sync::atomic::AtomicU64;
+use std::sync::atomic::{AtomicU64, Ordering};
 use std::time::{Duration, Instant as StdInstant};
 
-use rustc_data_structures::sync::Ordering;
-
-use crate::*;
-
-/// When using a virtual clock, this defines how many nanoseconds do we pretend
-/// are passing for each basic block.
-const NANOSECOND_PER_BASIC_BLOCK: u64 = 10;
+/// When using a virtual clock, this defines how many nanoseconds we pretend are passing for each
+/// basic block.
+const NANOSECONDS_PER_BASIC_BLOCK: u64 = 10;
 
 #[derive(Debug)]
 pub struct Instant {
@@ -83,7 +79,7 @@ pub fn tick(&self) {
                 // Time will pass without us doing anything.
             }
             ClockKind::Virtual { nanoseconds } => {
-                nanoseconds.fetch_add(NANOSECOND_PER_BASIC_BLOCK, Ordering::SeqCst);
+                nanoseconds.fetch_add(NANOSECONDS_PER_BASIC_BLOCK, Ordering::SeqCst);
             }
         }
     }
index 933c298ee4d506e14bb7f6002aa96376943c1d5e..f083ab499009994be03a277b91ea80e50cefbabb 100644 (file)
@@ -38,7 +38,7 @@ fn clock_gettime(
             [this.eval_libc_i32("CLOCK_MONOTONIC")?, this.eval_libc_i32("CLOCK_MONOTONIC_COARSE")?];
 
         let duration = if absolute_clocks.contains(&clk_id) {
-            this.check_no_isolation("`clock_gettime` with real time clocks")?;
+            this.check_no_isolation("`clock_gettime` with `REALTIME` clocks")?;
             system_time_to_duration(&SystemTime::now())?
         } else if relative_clocks.contains(&clk_id) {
             this.machine.clock.now().duration_since(this.machine.clock.anchor())
index 7e6c74d71cb8c21eadf8891bae699a6cd3073794..b6444319b59b9ca40dcd37544fed6ffc337b7ae9 100644 (file)
@@ -8,7 +8,7 @@ fn test_sleep() {
     assert!((after - before).as_secs() >= 3600);
 }
 
-/// Ensure that time passes even if we don't sleep (but just wor).
+/// Ensure that time passes even if we don't sleep (but just work).
 fn test_time_passes() {
     // Check `Instant`.
     let now1 = Instant::now();