aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_thread
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2018-09-12 13:33:45 -0400
committerGitHub <noreply@github.com>2018-09-12 13:33:45 -0400
commit910cc23a6e85cced43905f7615065b23bdb54b42 (patch)
tree3ceae959c0ebdf3f224c5c07f5b8c2cbd31dddf1 /components/layout_thread
parent9a83ab6297ddb62937fc54521b7fd4d19017e6b1 (diff)
parent2a996fbc8fef722b264389680cc55c25c46807d1 (diff)
downloadservo-910cc23a6e85cced43905f7615065b23bdb54b42.tar.gz
servo-910cc23a6e85cced43905f7615065b23bdb54b42.zip
Auto merge of #21325 - gterzian:crossbeam_integration, r=SimonSapin,jdm
Replace mpsc with crossbeam-channel Follow up on https://github.com/servo/servo/pull/19515 --- Selecting over multiple channels in `std::sync::mpsc` is not stable and likely never will be: https://github.com/rust-lang/rust/issues/27800#issuecomment-260136777 > It seems the only thing keeping `mpsc_select` around is Servo. crossbeam-channel is designed specifically to replace `std::sync::mpsc` and fix many of its shortcomings: https://github.com/stjepang/rfcs-crossbeam/blob/channel/text/2017-11-09-channel.md This is to be landed together with https://github.com/servo/ipc-channel/pull/183. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21325) <!-- Reviewable:end -->
Diffstat (limited to 'components/layout_thread')
-rw-r--r--components/layout_thread/Cargo.toml3
-rw-r--r--components/layout_thread/lib.rs31
2 files changed, 11 insertions, 23 deletions
diff --git a/components/layout_thread/Cargo.toml b/components/layout_thread/Cargo.toml
index a17f90e899e..2c76600dbfb 100644
--- a/components/layout_thread/Cargo.toml
+++ b/components/layout_thread/Cargo.toml
@@ -23,7 +23,7 @@ gfx = {path = "../gfx"}
gfx_traits = {path = "../gfx_traits"}
histogram = "0.6.8"
html5ever = "0.22"
-ipc-channel = "0.10"
+ipc-channel = "0.11"
layout = {path = "../layout"}
layout_traits = {path = "../layout_traits"}
lazy_static = "1"
@@ -46,6 +46,7 @@ serde_json = "1.0"
servo_allocator = {path = "../allocator"}
servo_arc = {path = "../servo_arc"}
servo_atoms = {path = "../atoms"}
+servo_channel = {path = "../channel"}
servo_config = {path = "../config"}
servo_geometry = {path = "../geometry"}
servo_url = {path = "../url"}
diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs
index aa520215cd2..3057701f360 100644
--- a/components/layout_thread/lib.rs
+++ b/components/layout_thread/lib.rs
@@ -5,8 +5,6 @@
//! The layout thread. Performs layout on the DOM, builds display lists and sends them to be
//! painted.
-#![feature(mpsc_select)]
-
extern crate app_units;
extern crate atomic_refcell;
extern crate embedder_traits;
@@ -44,6 +42,8 @@ extern crate serde_json;
extern crate servo_allocator;
extern crate servo_arc;
extern crate servo_atoms;
+#[macro_use]
+extern crate servo_channel;
extern crate servo_config;
extern crate servo_geometry;
extern crate servo_url;
@@ -67,7 +67,6 @@ use gfx::font_context;
use gfx_traits::{Epoch, node_id_from_scroll_id};
use histogram::Histogram;
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
-use ipc_channel::router::ROUTER;
use layout::animation;
use layout::construct::ConstructionResult;
use layout::context::LayoutContext;
@@ -111,6 +110,7 @@ use script_traits::Painter;
use selectors::Element;
use servo_arc::Arc as ServoArc;
use servo_atoms::Atom;
+use servo_channel::{Receiver, Sender, channel, route_ipc_receiver_to_new_servo_receiver};
use servo_config::opts;
use servo_config::prefs::PREFS;
use servo_geometry::MaxRect;
@@ -123,7 +123,6 @@ use std::ops::{Deref, DerefMut};
use std::process;
use std::sync::{Arc, Mutex, MutexGuard};
use std::sync::atomic::{AtomicUsize, Ordering};
-use std::sync::mpsc::{Receiver, Sender, channel};
use std::thread;
use style::animation::Animation;
use style::context::{QuirksMode, RegisteredSpeculativePainter, RegisteredSpeculativePainters};
@@ -504,12 +503,12 @@ impl LayoutThread {
let (new_animations_sender, new_animations_receiver) = channel();
// Proxy IPC messages from the pipeline to the layout thread.
- let pipeline_receiver = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(pipeline_port);
+ let pipeline_receiver = route_ipc_receiver_to_new_servo_receiver(pipeline_port);
// Ask the router to proxy IPC messages from the font cache thread to the layout thread.
let (ipc_font_cache_sender, ipc_font_cache_receiver) = ipc::channel().unwrap();
let font_cache_receiver =
- ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_font_cache_receiver);
+ route_ipc_receiver_to_new_servo_receiver(ipc_font_cache_receiver);
LayoutThread {
id: id,
@@ -639,22 +638,10 @@ impl LayoutThread {
FromFontCache,
}
- let request = {
- let port_from_script = &self.port;
- let port_from_pipeline = &self.pipeline_port;
- let port_from_font_cache = &self.font_cache_receiver;
- select! {
- msg = port_from_pipeline.recv() => {
- Request::FromPipeline(msg.unwrap())
- },
- msg = port_from_script.recv() => {
- Request::FromScript(msg.unwrap())
- },
- msg = port_from_font_cache.recv() => {
- msg.unwrap();
- Request::FromFontCache
- }
- }
+ let request = select! {
+ recv(self.pipeline_port.select(), msg) => Request::FromPipeline(msg.unwrap()),
+ recv(self.port.select(), msg) => Request::FromScript(msg.unwrap()),
+ recv(self.font_cache_receiver.select(), msg) => { msg.unwrap(); Request::FromFontCache }
};
match request {