servo: Merge #11313 - Hoist channel creation out of loop in handle_is_ready_to_save_image (from nox:channel-loop); r=mbrubeck

Source-Repo: https://github.com/servo/servo
Source-Revision: eeea481a121449c5dfba01a7598482c07e16d428
This commit is contained in:
Anthony Ramine 2016-05-21 08:32:30 -07:00
Родитель 2678783a29
Коммит 06b9f8ff58
1 изменённых файлов: 7 добавлений и 6 удалений

Просмотреть файл

@ -1735,6 +1735,9 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
return ReadyToSave::PendingFrames;
}
let (state_sender, state_receiver) = ipc::channel().expect("Failed to create IPC channel!");
let (epoch_sender, epoch_receiver) = ipc::channel().expect("Failed to create IPC channel!");
// Step through the current frame tree, checking that the script
// thread is idle, and that the current epoch of the layout thread
// matches what the compositor has painted. If all these conditions
@ -1757,12 +1760,11 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
// before we check whether the document is ready; otherwise,
// there's a race condition where a webfont has finished loading,
// but hasn't yet notified the document.
let (sender, receiver) = ipc::channel().expect("Failed to create IPC channel!");
let msg = LayoutControlMsg::GetWebFontLoadState(sender);
let msg = LayoutControlMsg::GetWebFontLoadState(state_sender.clone());
if let Err(e) = pipeline.layout_chan.0.send(msg) {
warn!("Get web font failed ({})", e);
}
if receiver.recv().unwrap_or(true) {
if state_receiver.recv().unwrap_or(true) {
return ReadyToSave::WebFontNotLoaded;
}
@ -1794,12 +1796,11 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
// epoch matches what the compositor has drawn. If they match
// (and script is idle) then this pipeline won't change again
// and can be considered stable.
let (sender, receiver) = ipc::channel().expect("Failed to create IPC channel!");
let LayoutControlChan(ref layout_chan) = pipeline.layout_chan;
if let Err(e) = layout_chan.send(LayoutControlMsg::GetCurrentEpoch(sender)) {
if let Err(e) = layout_chan.send(LayoutControlMsg::GetCurrentEpoch(epoch_sender.clone())) {
warn!("Failed to send GetCurrentEpoch ({}).", e);
}
match receiver.recv() {
match epoch_receiver.recv() {
Err(e) => warn!("Failed to receive current epoch ({}).", e),
Ok(layout_thread_epoch) => if layout_thread_epoch != *compositor_epoch {
return ReadyToSave::EpochMismatch;