aboutsummaryrefslogtreecommitdiffstats
path: root/components/constellation
diff options
context:
space:
mode:
Diffstat (limited to 'components/constellation')
-rw-r--r--components/constellation/Cargo.toml3
-rw-r--r--components/constellation/constellation.rs41
-rw-r--r--components/constellation/lib.rs4
-rw-r--r--components/constellation/network_listener.rs2
-rw-r--r--components/constellation/pipeline.rs4
-rw-r--r--components/constellation/timer_scheduler.rs34
6 files changed, 44 insertions, 44 deletions
diff --git a/components/constellation/Cargo.toml b/components/constellation/Cargo.toml
index ef740e8ee8f..e0c629096f6 100644
--- a/components/constellation/Cargo.toml
+++ b/components/constellation/Cargo.toml
@@ -23,7 +23,7 @@ embedder_traits = { path = "../embedder_traits" }
gfx = {path = "../gfx"}
gfx_traits = {path = "../gfx_traits"}
hyper = "0.10"
-ipc-channel = "0.10"
+ipc-channel = "0.11"
layout_traits = {path = "../layout_traits"}
log = "0.4"
metrics = {path = "../metrics"}
@@ -33,6 +33,7 @@ net_traits = {path = "../net_traits"}
profile_traits = {path = "../profile_traits"}
script_traits = {path = "../script_traits"}
serde = "1.0"
+servo_channel = {path = "../channel"}
style_traits = {path = "../style_traits"}
servo_config = {path = "../config"}
servo_rand = {path = "../rand"}
diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs
index a08768c06dc..826e0cd972f 100644
--- a/components/constellation/constellation.rs
+++ b/components/constellation/constellation.rs
@@ -132,6 +132,7 @@ use script_traits::{LogEntry, ScriptToConstellationChan, ServiceWorkerMsg, webdr
use script_traits::{SWManagerMsg, ScopeThings, UpdatePipelineIdReason, WebDriverCommandMsg};
use script_traits::{WindowSizeData, WindowSizeType};
use serde::{Deserialize, Serialize};
+use servo_channel::{Receiver, Sender, channel};
use servo_config::opts;
use servo_config::prefs::PREFS;
use servo_rand::{Rng, SeedableRng, ServoRng, random};
@@ -145,7 +146,6 @@ use std::mem::replace;
use std::process;
use std::rc::{Rc, Weak};
use std::sync::Arc;
-use std::sync::mpsc::{Receiver, Sender, channel};
use std::thread;
use style_traits::CSSPixel;
use style_traits::cursor::CursorKind;
@@ -875,7 +875,6 @@ where
}
/// Handles loading pages, navigation, and granting access to the compositor
- #[allow(unsafe_code)]
fn handle_request(&mut self) {
enum Request {
Script((PipelineId, FromScriptMsg)),
@@ -896,25 +895,23 @@ where
// produces undefined behaviour, resulting in the destructor
// being called. If this happens, there's not much we can do
// other than panic.
- let request = {
- let receiver_from_script = &self.script_receiver;
- let receiver_from_compositor = &self.compositor_receiver;
- let receiver_from_layout = &self.layout_receiver;
- let receiver_from_network_listener = &self.network_listener_receiver;
- let receiver_from_swmanager = &self.swmanager_receiver;
- select! {
- msg = receiver_from_script.recv() =>
- msg.expect("Unexpected script channel panic in constellation").map(Request::Script),
- msg = receiver_from_compositor.recv() =>
- Ok(Request::Compositor(msg.expect("Unexpected compositor channel panic in constellation"))),
- msg = receiver_from_layout.recv() =>
- msg.expect("Unexpected layout channel panic in constellation").map(Request::Layout),
- msg = receiver_from_network_listener.recv() =>
- Ok(Request::NetworkListener(
- msg.expect("Unexpected network listener channel panic in constellation")
- )),
- msg = receiver_from_swmanager.recv() =>
- msg.expect("Unexpected panic channel panic in constellation").map(Request::FromSWManager)
+ let request = select! {
+ recv(self.script_receiver.select(), msg) => {
+ msg.expect("Unexpected script channel panic in constellation").map(Request::Script)
+ }
+ recv(self.compositor_receiver.select(), msg) => {
+ Ok(Request::Compositor(msg.expect("Unexpected compositor channel panic in constellation")))
+ }
+ recv(self.layout_receiver.select(), msg) => {
+ msg.expect("Unexpected layout channel panic in constellation").map(Request::Layout)
+ }
+ recv(self.network_listener_receiver.select(), msg) => {
+ Ok(Request::NetworkListener(
+ msg.expect("Unexpected network listener channel panic in constellation")
+ ))
+ }
+ recv(self.swmanager_receiver.select(), msg) => {
+ msg.expect("Unexpected panic channel panic in constellation").map(Request::FromSWManager)
}
};
@@ -1442,7 +1439,7 @@ where
debug!("Exiting devtools.");
let msg = DevtoolsControlMsg::FromChrome(ChromeToDevtoolsControlMsg::ServerExitMsg);
if let Err(e) = chan.send(msg) {
- warn!("Exit devtools failed ({})", e);
+ warn!("Exit devtools failed ({:?})", e);
}
}
diff --git a/components/constellation/lib.rs b/components/constellation/lib.rs
index 1af7a3bfc4a..1e0e9ed8ed4 100644
--- a/components/constellation/lib.rs
+++ b/components/constellation/lib.rs
@@ -4,7 +4,6 @@
#![deny(unsafe_code)]
#![cfg_attr(feature = "unstable", feature(conservative_impl_trait))]
-#![feature(mpsc_select)]
extern crate backtrace;
extern crate bluetooth_traits;
@@ -32,8 +31,9 @@ extern crate net;
extern crate net_traits;
extern crate profile_traits;
extern crate script_traits;
-#[macro_use]
extern crate serde;
+#[macro_use]
+extern crate servo_channel;
extern crate servo_config;
extern crate servo_rand;
extern crate servo_remutex;
diff --git a/components/constellation/network_listener.rs b/components/constellation/network_listener.rs
index 823fca4608c..461be7990da 100644
--- a/components/constellation/network_listener.rs
+++ b/components/constellation/network_listener.rs
@@ -15,7 +15,7 @@ use net_traits::{CoreResourceMsg, FetchChannels, FetchMetadata, FetchResponseMsg
use net_traits::{IpcSend, NetworkError, ResourceThreads};
use net_traits::request::{Destination, RequestInit};
use net_traits::response::ResponseInit;
-use std::sync::mpsc::Sender;
+use servo_channel::Sender;
pub struct NetworkListener {
res_init: Option<ResponseInit>,
diff --git a/components/constellation/pipeline.rs b/components/constellation/pipeline.rs
index 62899328ca1..d45129db3c0 100644
--- a/components/constellation/pipeline.rs
+++ b/components/constellation/pipeline.rs
@@ -28,6 +28,7 @@ use script_traits::{DocumentActivity, InitialScriptState};
use script_traits::{LayoutControlMsg, LayoutMsg, LoadData};
use script_traits::{NewLayoutInfo, SWManagerMsg, SWManagerSenders};
use script_traits::{ScriptThreadFactory, TimerSchedulerMsg, WindowSizeData};
+use servo_channel::Sender;
use servo_config::opts::{self, Opts};
use servo_config::prefs::{PREFS, Pref};
use servo_url::ServoUrl;
@@ -38,7 +39,6 @@ use std::ffi::OsStr;
use std::process;
use std::rc::Rc;
use std::sync::Arc;
-use std::sync::mpsc::Sender;
use style_traits::CSSPixel;
use style_traits::DevicePixel;
use webrender_api;
@@ -255,7 +255,7 @@ impl Pipeline {
Ok(message) => if let Err(e) =
devtools_chan.send(DevtoolsControlMsg::FromScript(message))
{
- warn!("Sending to devtools failed ({})", e)
+ warn!("Sending to devtools failed ({:?})", e)
},
},
),
diff --git a/components/constellation/timer_scheduler.rs b/components/constellation/timer_scheduler.rs
index 989ea77e0af..6581c3f0916 100644
--- a/components/constellation/timer_scheduler.rs
+++ b/components/constellation/timer_scheduler.rs
@@ -4,10 +4,9 @@
use ipc_channel::ipc::{self, IpcSender};
use script_traits::{TimerEvent, TimerEventRequest, TimerSchedulerMsg};
+use servo_channel::base_channel;
use std::cmp::{self, Ord};
use std::collections::BinaryHeap;
-use std::sync::mpsc;
-use std::sync::mpsc::TryRecvError::{Disconnected, Empty};
use std::thread;
use std::time::{Duration, Instant};
@@ -40,7 +39,7 @@ impl PartialEq for ScheduledEvent {
impl TimerScheduler {
pub fn start() -> IpcSender<TimerSchedulerMsg> {
let (req_ipc_sender, req_ipc_receiver) = ipc::channel().expect("Channel creation failed.");
- let (req_sender, req_receiver) = mpsc::sync_channel(1);
+ let (req_sender, req_receiver) = base_channel::bounded(1);
// We could do this much more directly with recv_timeout
// (https://github.com/rust-lang/rfcs/issues/962).
@@ -70,26 +69,29 @@ impl TimerScheduler {
scheduled_events.pop();
}
// Look to see if there are any incoming events
- match req_receiver.try_recv() {
- // If there is an event, add it to the priority queue
- Ok(TimerSchedulerMsg::Request(req)) => {
- let TimerEventRequest(_, _, _, delay) = req;
- let schedule = Instant::now() + Duration::from_millis(delay.get());
- let event = ScheduledEvent {
- request: req,
- for_time: schedule,
- };
- scheduled_events.push(event);
+ select! {
+ recv(req_receiver, msg) => match msg {
+ // If there is an event, add it to the priority queue
+ Some(TimerSchedulerMsg::Request(req)) => {
+ let TimerEventRequest(_, _, _, delay) = req;
+ let schedule = Instant::now() + Duration::from_millis(delay.get());
+ let event = ScheduledEvent {
+ request: req,
+ for_time: schedule,
+ };
+ scheduled_events.push(event);
+ },
+ // If the channel is closed or we are shutting down, we are done.
+ Some(TimerSchedulerMsg::Exit) |
+ None => break,
},
// If there is no incoming event, park the thread,
// it will either be unparked when a new event arrives,
// or by a timeout.
- Err(Empty) => match scheduled_events.peek() {
+ default => match scheduled_events.peek() {
None => thread::park(),
Some(event) => thread::park_timeout(event.for_time - now),
},
- // If the channel is closed or we are shutting down, we are done.
- Ok(TimerSchedulerMsg::Exit) | Err(Disconnected) => break,
}
}
// This thread can terminate if the req_ipc_sender is dropped.