aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-11-01 18:26:20 -0500
committerGitHub <noreply@github.com>2016-11-01 18:26:20 -0500
commit1192aaa14d85f8be2f1ec6a1195755bc308f41ed (patch)
tree8b91ea5aa070a0665b5322f2c024a415f33adddb
parent070dee354204711eb085159fb9f234e080d181f4 (diff)
parent09cbe3bce032a965d613a4ae579a02d86a7c9e51 (diff)
downloadservo-1192aaa14d85f8be2f1ec6a1195755bc308f41ed.tar.gz
servo-1192aaa14d85f8be2f1ec6a1195755bc308f41ed.zip
Auto merge of #14008 - upsuper:rwlock, r=SimonSapin
Make style::context use parking_lot::RwLock <!-- Please describe your changes on the following line: --> The main motivation is to use `parking_lot::RwLock` instead of `sync::RwLock` in `style::context`, so that we can make `Stylesheet` be hold in a `parking_lot::RwLock` like other structs used for geckolib. r? @SimonSapin --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- 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/14008) <!-- Reviewable:end -->
-rw-r--r--components/layout/Cargo.toml1
-rw-r--r--components/layout/context.rs8
-rw-r--r--components/layout/lib.rs1
-rw-r--r--components/layout_thread/Cargo.toml1
-rw-r--r--components/layout_thread/lib.rs10
-rw-r--r--components/servo/Cargo.lock2
-rw-r--r--components/style/animation.rs4
-rw-r--r--components/style/context.rs3
-rw-r--r--components/style/gecko/data.rs3
-rw-r--r--components/style/matching.rs3
-rw-r--r--ports/cef/Cargo.lock2
11 files changed, 23 insertions, 15 deletions
diff --git a/components/layout/Cargo.toml b/components/layout/Cargo.toml
index 6b7dabd9f15..917b6b82e73 100644
--- a/components/layout/Cargo.toml
+++ b/components/layout/Cargo.toml
@@ -27,6 +27,7 @@ log = "0.3.5"
msg = {path = "../msg"}
net_traits = {path = "../net_traits"}
ordered-float = "0.2.2"
+parking_lot = {version = "0.3.3", features = ["nightly"]}
plugins = {path = "../plugins"}
profile_traits = {path = "../profile_traits"}
range = {path = "../range"}
diff --git a/components/layout/context.rs b/components/layout/context.rs
index 17a484e2930..0b3973eac05 100644
--- a/components/layout/context.rs
+++ b/components/layout/context.rs
@@ -16,11 +16,12 @@ use ipc_channel::ipc;
use net_traits::image::base::Image;
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread, ImageResponse, ImageState};
use net_traits::image_cache_thread::{ImageOrMetadataAvailable, UsePlaceholder};
+use parking_lot::RwLock;
use std::cell::{RefCell, RefMut};
use std::collections::HashMap;
use std::hash::BuildHasherDefault;
use std::rc::Rc;
-use std::sync::{Arc, Mutex, RwLock};
+use std::sync::{Arc, Mutex};
use style::context::{LocalStyleContext, StyleContext, SharedStyleContext};
use url::Url;
use util::opts;
@@ -194,7 +195,6 @@ impl SharedLayoutContext {
-> Option<WebRenderImageInfo> {
if let Some(existing_webrender_image) = self.webrender_image_cache
.read()
- .unwrap()
.get(&((*url).clone(), use_placeholder)) {
return Some((*existing_webrender_image).clone())
}
@@ -205,9 +205,7 @@ impl SharedLayoutContext {
if image_info.key.is_none() {
Some(image_info)
} else {
- let mut webrender_image_cache = self.webrender_image_cache
- .write()
- .unwrap();
+ let mut webrender_image_cache = self.webrender_image_cache.write();
webrender_image_cache.insert(((*url).clone(), use_placeholder),
image_info);
Some(image_info)
diff --git a/components/layout/lib.rs b/components/layout/lib.rs
index bff6eeca1ac..935a7631e23 100644
--- a/components/layout/lib.rs
+++ b/components/layout/lib.rs
@@ -36,6 +36,7 @@ extern crate log;
extern crate msg;
extern crate net_traits;
extern crate ordered_float;
+extern crate parking_lot;
#[macro_use]
#[no_link]
extern crate plugins as servo_plugins;
diff --git a/components/layout_thread/Cargo.toml b/components/layout_thread/Cargo.toml
index 37998d1b48b..368c6142980 100644
--- a/components/layout_thread/Cargo.toml
+++ b/components/layout_thread/Cargo.toml
@@ -25,6 +25,7 @@ lazy_static = "0.2"
log = "0.3.5"
msg = {path = "../msg"}
net_traits = {path = "../net_traits"}
+parking_lot = {version = "0.3.3", features = ["nightly"]}
plugins = {path = "../plugins"}
profile_traits = {path = "../profile_traits"}
script = {path = "../script"}
diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs
index 8016bb68b44..32231f1808b 100644
--- a/components/layout_thread/lib.rs
+++ b/components/layout_thread/lib.rs
@@ -32,6 +32,7 @@ extern crate lazy_static;
extern crate log;
extern crate msg;
extern crate net_traits;
+extern crate parking_lot;
#[macro_use]
extern crate profile_traits;
extern crate script;
@@ -83,6 +84,7 @@ use layout_traits::LayoutThreadFactory;
use msg::constellation_msg::PipelineId;
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheResult, ImageCacheThread};
use net_traits::image_cache_thread::UsePlaceholder;
+use parking_lot::RwLock;
use profile_traits::mem::{self, Report, ReportKind, ReportsChan};
use profile_traits::time::{self, TimerMetadata, profile};
use profile_traits::time::{TimerMetadataFrameType, TimerMetadataReflowType};
@@ -101,7 +103,7 @@ use std::collections::HashMap;
use std::hash::BuildHasherDefault;
use std::ops::{Deref, DerefMut};
use std::process;
-use std::sync::{Arc, Mutex, MutexGuard, RwLock};
+use std::sync::{Arc, Mutex, MutexGuard};
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::mpsc::{Receiver, Sender, channel};
use style::animation::Animation;
@@ -1316,7 +1318,7 @@ impl LayoutThread {
if let Some(mut root_flow) = self.root_flow.clone() {
// Perform an abbreviated style recalc that operates without access to the DOM.
- let animations = self.running_animations.read().unwrap();
+ let animations = self.running_animations.read();
profile(time::ProfilerCategory::LayoutStyleRecalc,
self.profiler_metadata(),
self.time_profiler_chan.clone(),
@@ -1368,8 +1370,8 @@ impl LayoutThread {
// Kick off animations if any were triggered, expire completed ones.
animation::update_animation_state(&self.constellation_chan,
&self.script_chan,
- &mut *self.running_animations.write().unwrap(),
- &mut *self.expired_animations.write().unwrap(),
+ &mut *self.running_animations.write(),
+ &mut *self.expired_animations.write(),
&self.new_animations_receiver,
self.id,
&self.timer);
diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock
index 0936aa8f0fc..7cdf39b2fc8 100644
--- a/components/servo/Cargo.lock
+++ b/components/servo/Cargo.lock
@@ -1149,6 +1149,7 @@ dependencies = [
"msg 0.0.1",
"net_traits 0.0.1",
"ordered-float 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "parking_lot 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"plugins 0.0.1",
"profile_traits 0.0.1",
"range 0.0.1",
@@ -1194,6 +1195,7 @@ dependencies = [
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1",
"net_traits 0.0.1",
+ "parking_lot 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"plugins 0.0.1",
"profile_traits 0.0.1",
"script 0.0.1",
diff --git a/components/style/animation.rs b/components/style/animation.rs
index 3cdc057d532..898dd8ee449 100644
--- a/components/style/animation.rs
+++ b/components/style/animation.rs
@@ -672,7 +672,7 @@ pub fn complete_expired_transitions(node: OpaqueNode, style: &mut Arc<ComputedVa
context: &SharedStyleContext) -> bool {
let had_animations_to_expire;
{
- let all_expired_animations = context.expired_animations.read().unwrap();
+ let all_expired_animations = context.expired_animations.read();
let animations_to_expire = all_expired_animations.get(&node);
had_animations_to_expire = animations_to_expire.is_some();
if let Some(ref animations) = animations_to_expire {
@@ -686,7 +686,7 @@ pub fn complete_expired_transitions(node: OpaqueNode, style: &mut Arc<ComputedVa
}
if had_animations_to_expire {
- context.expired_animations.write().unwrap().remove(&node);
+ context.expired_animations.write().remove(&node);
}
had_animations_to_expire
diff --git a/components/style/context.rs b/components/style/context.rs
index f25094140fa..fc3724452a7 100644
--- a/components/style/context.rs
+++ b/components/style/context.rs
@@ -10,10 +10,11 @@ use dom::OpaqueNode;
use error_reporting::ParseErrorReporter;
use euclid::Size2D;
use matching::{ApplicableDeclarationsCache, StyleSharingCandidateCache};
+use parking_lot::RwLock;
use selector_matching::Stylist;
use std::cell::RefCell;
use std::collections::HashMap;
-use std::sync::{Arc, Mutex, RwLock};
+use std::sync::{Arc, Mutex};
use std::sync::mpsc::Sender;
use timer::Timer;
diff --git a/components/style/gecko/data.rs b/components/style/gecko/data.rs
index e9d6dbf8627..1cc360fdeb8 100644
--- a/components/style/gecko/data.rs
+++ b/components/style/gecko/data.rs
@@ -12,11 +12,12 @@ use gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI};
use media_queries::{Device, MediaType};
use num_cpus;
use parallel::WorkQueueData;
+use parking_lot::RwLock;
use selector_matching::Stylist;
use std::cmp;
use std::collections::HashMap;
use std::env;
-use std::sync::{Arc, RwLock};
+use std::sync::Arc;
use std::sync::mpsc::{Receiver, Sender, channel};
use style_traits::ViewportPx;
use stylesheets::Stylesheet;
diff --git a/components/style/matching.rs b/components/style/matching.rs
index 3ede17edc38..6de269477a4 100644
--- a/components/style/matching.rs
+++ b/components/style/matching.rs
@@ -605,11 +605,10 @@ trait PrivateMatchMethods: TElement {
// Merge any running transitions into the current style, and cancel them.
let had_running_animations = context.running_animations
.read()
- .unwrap()
.get(&this_opaque)
.is_some();
if had_running_animations {
- let mut all_running_animations = context.running_animations.write().unwrap();
+ let mut all_running_animations = context.running_animations.write();
for mut running_animation in all_running_animations.get_mut(&this_opaque).unwrap() {
// This shouldn't happen frequently, but under some
// circumstances mainly huge load or debug builds, the
diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock
index 754b36a64d0..0513c40b90e 100644
--- a/ports/cef/Cargo.lock
+++ b/ports/cef/Cargo.lock
@@ -1056,6 +1056,7 @@ dependencies = [
"msg 0.0.1",
"net_traits 0.0.1",
"ordered-float 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "parking_lot 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"plugins 0.0.1",
"profile_traits 0.0.1",
"range 0.0.1",
@@ -1094,6 +1095,7 @@ dependencies = [
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1",
"net_traits 0.0.1",
+ "parking_lot 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"plugins 0.0.1",
"profile_traits 0.0.1",
"script 0.0.1",