Replace mpsc with crossbeam/servo channel, update ipc-channel

Co-authored-by: Gregory Terzian <gterzian@users.noreply.github.com>
This commit is contained in:
Simon Sapin 2017-12-17 23:53:32 +01:00 committed by Gregory Terzian
parent b977b4994c
commit 2a996fbc8f
89 changed files with 341 additions and 377 deletions

View file

@ -19,13 +19,14 @@ euclid = "0.19"
gfx_traits = {path = "../gfx_traits"}
gleam = {version = "0.6", optional = true}
image = "0.19"
ipc-channel = "0.10"
ipc-channel = "0.11"
libc = "0.2"
log = "0.4"
msg = {path = "../msg"}
net_traits = {path = "../net_traits"}
profile_traits = {path = "../profile_traits"}
script_traits = {path = "../script_traits"}
servo_channel = {path = "../channel"}
servo_config = {path = "../config"}
servo_geometry = {path = "../geometry"}
servo_url = {path = "../url"}

View file

@ -23,6 +23,7 @@ use script_traits::{AnimationState, AnimationTickType, ConstellationMsg, LayoutC
use script_traits::{MouseButton, MouseEventType, ScrollState, TouchEventType, TouchId};
use script_traits::{UntrustedNodeAddress, WindowSizeData, WindowSizeType};
use script_traits::CompositorEvent::{MouseMoveEvent, MouseButtonEvent, TouchEvent};
use servo_channel::Sender;
use servo_config::opts;
use servo_geometry::DeviceIndependentPixel;
use std::collections::HashMap;
@ -31,7 +32,6 @@ use std::fs::{File, create_dir_all};
use std::io::Write;
use std::num::NonZeroU32;
use std::rc::Rc;
use std::sync::mpsc::Sender;
use std::time::Instant;
use style_traits::{CSSPixel, DevicePixel, PinchZoomFactor};
use style_traits::cursor::CursorKind;
@ -358,7 +358,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
fn start_shutting_down(&mut self) {
debug!("Compositor sending Exit message to Constellation");
if let Err(e) = self.constellation_chan.send(ConstellationMsg::Exit) {
warn!("Sending exit message to constellation failed ({}).", e);
warn!("Sending exit message to constellation failed ({:?}).", e);
}
self.shutdown_state = ShutdownState::ShuttingDown;
@ -420,7 +420,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
}
let img = res.unwrap_or(None);
if let Err(e) = reply.send(img) {
warn!("Sending reply to create png failed ({}).", e);
warn!("Sending reply to create png failed ({:?}).", e);
}
},
@ -494,19 +494,19 @@ impl<Window: WindowMethods> IOCompositor<Window> {
(Msg::GetClientWindow(req), ShutdownState::NotShuttingDown) => {
if let Err(e) = req.send(self.embedder_coordinates.window) {
warn!("Sending response to get client window failed ({}).", e);
warn!("Sending response to get client window failed ({:?}).", e);
}
},
(Msg::GetScreenSize(req), ShutdownState::NotShuttingDown) => {
if let Err(e) = req.send(self.embedder_coordinates.screen) {
warn!("Sending response to get screen size failed ({}).", e);
warn!("Sending response to get screen size failed ({:?}).", e);
}
},
(Msg::GetScreenAvailSize(req), ShutdownState::NotShuttingDown) => {
if let Err(e) = req.send(self.embedder_coordinates.screen_avail) {
warn!("Sending response to get screen avail size failed ({}).", e);
warn!("Sending response to get screen avail size failed ({:?}).", e);
}
},
@ -634,7 +634,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
let msg = ConstellationMsg::WindowSize(top_level_browsing_context_id, data, size_type);
if let Err(e) = self.constellation_chan.send(msg) {
warn!("Sending window resize to constellation failed ({}).", e);
warn!("Sending window resize to constellation failed ({:?}).", e);
}
}
@ -701,7 +701,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
let pipeline_id = PipelineId::from_webrender(result.pipeline);
let msg = ConstellationMsg::ForwardEvent(pipeline_id, event_to_send);
if let Err(e) = self.constellation_chan.send(msg) {
warn!("Sending event to constellation failed ({}).", e);
warn!("Sending event to constellation failed ({:?}).", e);
}
}
@ -743,13 +743,13 @@ impl<Window: WindowMethods> IOCompositor<Window> {
let pipeline_id = PipelineId::from_webrender(item.pipeline);
let msg = ConstellationMsg::ForwardEvent(pipeline_id, event);
if let Err(e) = self.constellation_chan.send(msg) {
warn!("Sending event to constellation failed ({}).", e);
warn!("Sending event to constellation failed ({:?}).", e);
}
if let Some(cursor) = CursorKind::from_u8(item.tag.1 as _).ok() {
let msg = ConstellationMsg::SetCursor(cursor);
if let Err(e) = self.constellation_chan.send(msg) {
warn!("Sending event to constellation failed ({}).", e);
warn!("Sending event to constellation failed ({:?}).", e);
}
}
}
@ -772,7 +772,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
let pipeline_id = PipelineId::from_webrender(item.pipeline);
let msg = ConstellationMsg::ForwardEvent(pipeline_id, event);
if let Err(e) = self.constellation_chan.send(msg) {
warn!("Sending event to constellation failed ({}).", e);
warn!("Sending event to constellation failed ({:?}).", e);
}
}
}
@ -1008,7 +1008,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
if animation_callbacks_running {
let msg = ConstellationMsg::TickAnimation(pipeline_id, AnimationTickType::Script);
if let Err(e) = self.constellation_chan.send(msg) {
warn!("Sending tick to constellation failed ({}).", e);
warn!("Sending tick to constellation failed ({:?}).", e);
}
}
@ -1017,7 +1017,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
if animations_running {
let msg = ConstellationMsg::TickAnimation(pipeline_id, AnimationTickType::Layout);
if let Err(e) = self.constellation_chan.send(msg) {
warn!("Sending tick to constellation failed ({}).", e);
warn!("Sending tick to constellation failed ({:?}).", e);
}
}
}
@ -1160,7 +1160,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
// if it's safe to output the image.
let msg = ConstellationMsg::IsReadyToSaveImage(pipeline_epochs);
if let Err(e) = self.constellation_chan.send(msg) {
warn!("Sending ready to save to constellation failed ({}).", e);
warn!("Sending ready to save to constellation failed ({:?}).", e);
}
self.ready_to_save_state = ReadyState::WaitingForConstellationReply;
Err(NotReadyToPaint::JustNotifiedConstellation)
@ -1288,8 +1288,8 @@ impl<Window: WindowMethods> IOCompositor<Window> {
if let Some(pipeline) = self.pipeline(*id) {
// and inform the layout thread with the measured paint time.
let msg = LayoutControlMsg::PaintMetric(epoch, paint_time);
if let Err(e) = pipeline.layout_chan.send(msg) {
warn!("Sending PaintMetric message to layout failed ({}).", e);
if let Err(e) = pipeline.layout_chan.send(msg) {
warn!("Sending PaintMetric message to layout failed ({:?}).", e);
}
}
}

View file

@ -14,8 +14,8 @@ use net_traits::image::base::Image;
use profile_traits::mem;
use profile_traits::time;
use script_traits::{AnimationState, ConstellationMsg, EventResult};
use servo_channel::{Receiver, Sender};
use std::fmt::{Debug, Error, Formatter};
use std::sync::mpsc::{Receiver, Sender};
use style_traits::viewport::ViewportConstraints;
use webrender;
use webrender_api::{self, DeviceIntPoint, DeviceUintSize};
@ -28,9 +28,8 @@ pub struct CompositorProxy {
impl CompositorProxy {
pub fn send(&self, msg: Msg) {
// Send a message and kick the OS event loop awake.
if let Err(err) = self.sender.send(msg) {
warn!("Failed to send response ({}).", err);
warn!("Failed to send response ({:?}).", err);
}
self.event_loop_waker.wake();
}
@ -52,7 +51,7 @@ pub struct CompositorReceiver {
impl CompositorReceiver {
pub fn try_recv_compositor_msg(&mut self) -> Option<Msg> {
self.receiver.try_recv().ok()
self.receiver.try_recv()
}
pub fn recv_compositor_msg(&mut self) -> Msg {
self.receiver.recv().unwrap()

View file

@ -19,6 +19,7 @@ extern crate msg;
extern crate net_traits;
extern crate profile_traits;
extern crate script_traits;
extern crate servo_channel;
extern crate servo_config;
extern crate servo_geometry;
extern crate servo_url;