aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/style/gecko/global_style_data.rs28
-rw-r--r--ports/geckolib/glue.rs9
2 files changed, 22 insertions, 15 deletions
diff --git a/components/style/gecko/global_style_data.rs b/components/style/gecko/global_style_data.rs
index 0f80a18816e..f396a4ee451 100644
--- a/components/style/gecko/global_style_data.rs
+++ b/components/style/gecko/global_style_data.rs
@@ -16,12 +16,6 @@ use std::ffi::CString;
/// Global style data
pub struct GlobalStyleData {
- /// How many threads parallel styling can use.
- pub num_threads: usize,
-
- /// The parallel styling thread pool.
- pub style_thread_pool: Option<rayon::ThreadPool>,
-
/// Shared RWLock for CSSOM objects
pub shared_lock: SharedRwLock,
@@ -29,6 +23,15 @@ pub struct GlobalStyleData {
pub options: StyleSystemOptions,
}
+/// Global thread pool
+pub struct StyleThreadPool {
+ /// How many threads parallel styling can use.
+ pub num_threads: usize,
+
+ /// The parallel styling thread pool.
+ pub style_thread_pool: Option<rayon::ThreadPool>,
+}
+
fn thread_name(index: usize) -> String {
format!("StyleThread#{}", index)
}
@@ -53,8 +56,8 @@ fn thread_shutdown(_: usize) {
}
lazy_static! {
- /// Global style data
- pub static ref GLOBAL_STYLE_DATA: GlobalStyleData = {
+ /// Global thread pool
+ pub static ref STYLE_THREAD_POOL: StyleThreadPool = {
let stylo_threads = env::var("STYLO_THREADS")
.map(|s| s.parse::<usize>().expect("invalid STYLO_THREADS value"));
let mut num_threads = match stylo_threads {
@@ -93,11 +96,14 @@ lazy_static! {
pool
};
- GlobalStyleData {
+ StyleThreadPool {
num_threads: num_threads,
style_thread_pool: pool,
- shared_lock: SharedRwLock::new(),
- options: StyleSystemOptions::default(),
}
};
+ /// Global style data
+ pub static ref GLOBAL_STYLE_DATA: GlobalStyleData = GlobalStyleData {
+ shared_lock: SharedRwLock::new(),
+ options: StyleSystemOptions::default(),
+ };
}
diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs
index 5ef3d30e354..f9f57cb48c3 100644
--- a/ports/geckolib/glue.rs
+++ b/ports/geckolib/glue.rs
@@ -19,7 +19,7 @@ use style::element_state::ElementState;
use style::error_reporting::RustLogReporter;
use style::font_metrics::{FontMetricsProvider, get_metrics_provider_for_product};
use style::gecko::data::{PerDocumentStyleData, PerDocumentStyleDataImpl};
-use style::gecko::global_style_data::{GLOBAL_STYLE_DATA, GlobalStyleData};
+use style::gecko::global_style_data::{GLOBAL_STYLE_DATA, GlobalStyleData, STYLE_THREAD_POOL};
use style::gecko::restyle_damage::GeckoRestyleDamage;
use style::gecko::selector_parser::PseudoElement;
use style::gecko::traversal::RecalcStyleOnly;
@@ -227,7 +227,8 @@ fn traverse_subtree(element: GeckoElement,
debug!("Traversing subtree:");
debug!("{:?}", ShowSubtreeData(element.as_node()));
- let traversal_driver = if global_style_data.style_thread_pool.is_none() || !element.is_root() {
+ let style_thread_pool = &*STYLE_THREAD_POOL;
+ let traversal_driver = if style_thread_pool.style_thread_pool.is_none() || !element.is_root() {
TraversalDriver::Sequential
} else {
TraversalDriver::Parallel
@@ -236,7 +237,7 @@ fn traverse_subtree(element: GeckoElement,
let traversal = RecalcStyleOnly::new(shared_style_context, traversal_driver);
if traversal_driver.is_parallel() {
parallel::traverse_dom(&traversal, element, token,
- global_style_data.style_thread_pool.as_ref().unwrap());
+ style_thread_pool.style_thread_pool.as_ref().unwrap());
} else {
sequential::traverse_dom(&traversal, element, token);
}
@@ -729,7 +730,7 @@ pub extern "C" fn Servo_Property_IsDiscreteAnimatable(property: nsCSSPropertyID)
#[no_mangle]
pub extern "C" fn Servo_StyleWorkerThreadCount() -> u32 {
- GLOBAL_STYLE_DATA.num_threads as u32
+ STYLE_THREAD_POOL.num_threads as u32
}
#[no_mangle]