Make style context use parking_lot::RwLock

This commit is contained in:
Xidorn Quan 2016-11-01 11:43:16 +11:00
parent 070dee3542
commit 09cbe3bce0
11 changed files with 23 additions and 15 deletions

View file

@ -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

View file

@ -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;

View file

@ -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;

View file

@ -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