Skip to content

Commit 1535e29

Browse files
committed
⚡ - Decrease latency of watcher and and sleep at the end instead of the the beginning
1 parent 5cb90c6 commit 1535e29

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/watcher.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ async fn async_watch(
1515
after_build: Option<String>,
1616
) -> notify::Result<()> {
1717
loop {
18-
// We want to sleep for a little while so the CPU can schedule other work. That way we end
19-
// up not burning CPU cycles.
20-
Delay::new(Duration::from_millis(50)).await;
2118
let mut events: Vec<Event> = vec![];
2219
while !q.is_empty() {
2320
match q.pop() {
@@ -56,7 +53,7 @@ async fn async_watch(
5653

5754
if needs_compile {
5855
// Wait for events to settle
59-
Delay::new(Duration::from_millis(300)).await;
56+
Delay::new(Duration::from_millis(50)).await;
6057

6158
// Flush any remaining events that came in before
6259
while !q.is_empty() {
@@ -66,6 +63,9 @@ async fn async_watch(
6663
let _ = build::build(filter, path, false);
6764
after_build.clone().map(|command| cmd::run(command));
6865
}
66+
// We want to sleep for a little while so the CPU can schedule other work. That way we end
67+
// up not burning CPU cycles.
68+
Delay::new(Duration::from_millis(50)).await;
6969
}
7070
}
7171

0 commit comments

Comments
 (0)