mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Move sleeping code to match
block and comment
This commit is contained in:
parent
35b7527db6
commit
63d69dbe9f
1 changed files with 7 additions and 6 deletions
|
@ -686,7 +686,13 @@ impl Window {
|
||||||
close_event = self.handle_window_event(event) || close_event;
|
close_event = self.handle_window_event(event) || close_event;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WindowKind::Headless(..) => {}
|
WindowKind::Headless(..) => {
|
||||||
|
// Sleep the main thread to avoid using 100% CPU
|
||||||
|
// This can be done better, see comments in #18777
|
||||||
|
if events.is_empty() {
|
||||||
|
thread::sleep(time::Duration::from_millis(5));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
close_event = self.handle_next_event();
|
close_event = self.handle_next_event();
|
||||||
|
@ -697,11 +703,6 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
events.extend(mem::replace(&mut *self.event_queue.borrow_mut(), Vec::new()).into_iter());
|
events.extend(mem::replace(&mut *self.event_queue.borrow_mut(), Vec::new()).into_iter());
|
||||||
|
|
||||||
if opts::get().headless && events.is_empty() {
|
|
||||||
thread::sleep(time::Duration::from_millis(5));
|
|
||||||
}
|
|
||||||
|
|
||||||
events
|
events
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue