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 -->
This commit is contained in:
bors-servo 2018-09-12 13:33:45 -04:00 committed by GitHub
commit 910cc23a6e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
93 changed files with 590 additions and 385 deletions

View file

@ -94,6 +94,7 @@ use script_traits::{TimerSchedulerMsg, UntrustedNodeAddress, WindowSizeData, Win
use script_traits::webdriver_msg::{WebDriverJSError, WebDriverJSResult};
use selectors::attr::CaseSensitivity;
use servo_arc;
use servo_channel::{channel, Sender};
use servo_config::opts;
use servo_geometry::{f32_rect_to_au_rect, MaxRect};
use servo_url::{Host, MutableOrigin, ImmutableOrigin, ServoUrl};
@ -109,8 +110,6 @@ use std::mem;
use std::rc::Rc;
use std::sync::{Arc, Mutex};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::{Sender, channel};
use std::sync::mpsc::TryRecvError::{Disconnected, Empty};
use style::error_reporting::ParseErrorReporter;
use style::media_queries;
use style::parser::ParserContext as CssParserContext;
@ -1376,15 +1375,16 @@ impl Window {
debug!("script: layout forked");
let complete = match join_port.try_recv() {
Err(Empty) => {
let complete = select! {
recv(join_port.select(), msg) => if let Some(reflow_complete) = msg {
reflow_complete
} else {
panic!("Layout thread failed while script was waiting for a result.");
},
default => {
info!("script: waiting on layout");
join_port.recv().unwrap()
}
Ok(reflow_complete) => reflow_complete,
Err(Disconnected) => {
panic!("Layout thread failed while script was waiting for a result.");
}
};
debug!("script: layout joined");