aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_thread_2020/lib.rs
diff options
context:
space:
mode:
authorKunal Mohan <kunalmohan99@gmail.com>2020-02-22 16:10:32 +0530
committerKunal Mohan <kunalmohan99@gmail.com>2020-02-23 01:45:52 +0530
commita05553f188cb43cb9aa04440795447253261d5b5 (patch)
treec595602986014bd27a4830052376ed760e45771e /components/layout_thread_2020/lib.rs
parentada95b98786fd4bdaefdcf3be7626a85314a7b3a (diff)
downloadservo-a05553f188cb43cb9aa04440795447253261d5b5.tar.gz
servo-a05553f188cb43cb9aa04440795447253261d5b5.zip
Make Background Hang Monitor Optional
This is done by wrapping all channels of communication and related objects inside Option which are configured using flag inside servo_config.
Diffstat (limited to 'components/layout_thread_2020/lib.rs')
-rw-r--r--components/layout_thread_2020/lib.rs24
1 files changed, 15 insertions, 9 deletions
diff --git a/components/layout_thread_2020/lib.rs b/components/layout_thread_2020/lib.rs
index be24d768595..2972f7ef46f 100644
--- a/components/layout_thread_2020/lib.rs
+++ b/components/layout_thread_2020/lib.rs
@@ -137,7 +137,7 @@ pub struct LayoutThread {
font_cache_sender: IpcSender<()>,
/// A means of communication with the background hang monitor.
- background_hang_monitor: Box<dyn BackgroundHangMonitor>,
+ background_hang_monitor: Option<Box<dyn BackgroundHangMonitor>>,
/// The channel on which messages can be sent to the script thread.
script_chan: IpcSender<ConstellationControlMsg>,
@@ -247,7 +247,7 @@ impl LayoutThreadFactory for LayoutThread {
is_iframe: bool,
chan: (Sender<Msg>, Receiver<Msg>),
pipeline_port: IpcReceiver<LayoutControlMsg>,
- background_hang_monitor_register: Box<dyn BackgroundHangMonitorRegister>,
+ background_hang_monitor_register: Option<Box<dyn BackgroundHangMonitorRegister>>,
constellation_chan: IpcSender<ConstellationMsg>,
script_chan: IpcSender<ConstellationControlMsg>,
image_cache: Arc<dyn ImageCache>,
@@ -281,12 +281,13 @@ impl LayoutThreadFactory for LayoutThread {
// Ensures layout thread is destroyed before we send shutdown message
let sender = chan.0;
- let background_hang_monitor = background_hang_monitor_register
- .register_component(
+ let background_hang_monitor = background_hang_monitor_register.map(|bhm| {
+ bhm.register_component(
MonitoredComponentId(id, MonitoredComponentType::Layout),
Duration::from_millis(1000),
Duration::from_millis(5000),
- );
+ )
+ });
let layout = LayoutThread::new(
id,
@@ -463,7 +464,7 @@ impl LayoutThread {
is_iframe: bool,
port: Receiver<Msg>,
pipeline_port: IpcReceiver<LayoutControlMsg>,
- background_hang_monitor: Box<dyn BackgroundHangMonitor>,
+ background_hang_monitor: Option<Box<dyn BackgroundHangMonitor>>,
constellation_chan: IpcSender<ConstellationMsg>,
script_chan: IpcSender<ConstellationControlMsg>,
image_cache: Arc<dyn ImageCache>,
@@ -648,7 +649,8 @@ impl LayoutThread {
Msg::GetRunningAnimations(..) => LayoutHangAnnotation::GetRunningAnimations,
};
self.background_hang_monitor
- .notify_activity(HangAnnotation::Layout(hang_annotation));
+ .as_ref()
+ .map(|bhm| bhm.notify_activity(HangAnnotation::Layout(hang_annotation)));
}
/// Receives and dispatches messages from the script and constellation threads
@@ -660,7 +662,9 @@ impl LayoutThread {
}
// Notify the background-hang-monitor we are waiting for an event.
- self.background_hang_monitor.notify_wait();
+ self.background_hang_monitor
+ .as_ref()
+ .map(|bhm| bhm.notify_wait());
let request = select! {
recv(self.pipeline_port) -> msg => Request::FromPipeline(msg.unwrap()),
@@ -895,7 +899,9 @@ impl LayoutThread {
}
fn exit_now(&mut self) {
- self.background_hang_monitor.unregister();
+ self.background_hang_monitor
+ .as_ref()
+ .map(|bhm| bhm.unregister());
}
fn handle_add_stylesheet(&self, stylesheet: &Stylesheet, guard: &SharedRwLockReadGuard) {