mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Improved headless Servo performance
Now the main thread doesn't waste 100% CPU
This commit is contained in:
parent
72834c3482
commit
35b7527db6
1 changed files with 7 additions and 0 deletions
|
@ -39,6 +39,8 @@ use std::mem;
|
|||
use std::os::raw::c_void;
|
||||
use std::ptr;
|
||||
use std::rc::Rc;
|
||||
use std::thread;
|
||||
use std::time;
|
||||
use style_traits::DevicePixel;
|
||||
use style_traits::cursor::Cursor;
|
||||
#[cfg(target_os = "windows")]
|
||||
|
@ -695,6 +697,11 @@ impl Window {
|
|||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue