Use more precice timestamp in hot reloading

This commit is contained in:
Evan Almloff committed 2023-05-19 12:33:07 -05:00
1 parent c97f43146d
commit 383e7e6a58
1 file changed
+2 -3
+2 -3
View File
@@ -194,7 +194,6 @@ pub fn init<Ctx: HotReloadingContext + Send + 'static>(cfg: Config<Ctx>) {
println!("Connected to hot reloading 🚀"); println!("Connected to hot reloading 🚀");
} }
} }
std::thread::sleep(std::time::Duration::from_millis(10));
if *aborted.lock().unwrap() { if *aborted.lock().unwrap() {
break; break;
} }
@@ -250,7 +249,7 @@ pub fn init<Ctx: HotReloadingContext + Send + 'static>(cfg: Config<Ctx>) {
}; };
for evt in rx { for evt in rx {
if chrono::Local::now().timestamp() > last_update_time { if chrono::Local::now().timestamp_millis() >= last_update_time {
if let Ok(evt) = evt { if let Ok(evt) = evt {
let real_paths = evt let real_paths = evt
.paths .paths
@@ -322,7 +321,7 @@ pub fn init<Ctx: HotReloadingContext + Send + 'static>(cfg: Config<Ctx>) {
} }
} }
} }
last_update_time = chrono::Local::now().timestamp(); last_update_time = chrono::Local::now().timestamp_millis();
} }
} }
}); });