aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Froyd <froydnj@gmail.com>2017-02-22 11:22:16 -0500
committerNathan Froyd <froydnj@gmail.com>2017-02-22 11:35:08 -0500
commitfafcdda16ab8f39c15e8b3b6fb20526540d47d24 (patch)
tree1ee75eec7419dced2445304d68a7012b4493e630
parent3e81f8431e4e47c3c042cb4527582d6b5cdaf0ac (diff)
downloadservo-fafcdda16ab8f39c15e8b3b6fb20526540d47d24.tar.gz
servo-fafcdda16ab8f39c15e8b3b6fb20526540d47d24.zip
geckolib: move NUM_THREADS from style to geckolib
This change eliminates some gecko-only configuration in the style component and moves NUM_THREADS closer to its only uses.
-rw-r--r--Cargo.lock1
-rw-r--r--components/style/Cargo.toml6
-rw-r--r--components/style/gecko/data.rs13
-rw-r--r--components/style/lib.rs1
-rw-r--r--ports/geckolib/glue.rs14
-rw-r--r--ports/geckolib/lib.rs1
6 files changed, 15 insertions, 21 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 8561d429649..b66e4ffe5ed 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2719,7 +2719,6 @@ dependencies = [
"nsstring_vendor 0.1.0",
"num-integer 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
- "num_cpus 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"ordered-float 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"owning_ref 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/components/style/Cargo.toml b/components/style/Cargo.toml
index 563c7ed0967..7576ec4b7ea 100644
--- a/components/style/Cargo.toml
+++ b/components/style/Cargo.toml
@@ -13,7 +13,7 @@ path = "lib.rs"
doctest = false
[features]
-gecko = ["nsstring_vendor", "num_cpus", "rayon/unstable"]
+gecko = ["nsstring_vendor", "rayon/unstable"]
use_bindgen = ["bindgen", "regex"]
servo = ["serde/unstable", "serde", "serde_derive", "heapsize_derive",
"style_traits/servo", "servo_atoms", "html5ever-atoms",
@@ -57,10 +57,6 @@ servo_url = {path = "../url"}
time = "0.1"
unicode-segmentation = "1.0"
-[dependencies.num_cpus]
-optional = true
-version = "1.0"
-
[target.'cfg(windows)'.dependencies]
kernel32-sys = "0.2"
diff --git a/components/style/gecko/data.rs b/components/style/gecko/data.rs
index 916680dad39..89c18fa6a06 100644
--- a/components/style/gecko/data.rs
+++ b/components/style/gecko/data.rs
@@ -11,12 +11,9 @@ use gecko_bindings::bindings::RawServoStyleSet;
use gecko_bindings::structs::RawGeckoPresContextOwned;
use gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI};
use media_queries::Device;
-use num_cpus;
use parking_lot::RwLock;
use properties::ComputedValues;
-use std::cmp;
use std::collections::HashMap;
-use std::env;
use std::sync::Arc;
use std::sync::mpsc::{Receiver, Sender, channel};
use stylesheets::Stylesheet;
@@ -53,16 +50,6 @@ pub struct PerDocumentStyleDataImpl {
/// and unexpected races while trying to mutate it.
pub struct PerDocumentStyleData(AtomicRefCell<PerDocumentStyleDataImpl>);
-lazy_static! {
- /// The number of layout threads, computed statically.
- pub static ref NUM_THREADS: usize = {
- match env::var("STYLO_THREADS").map(|s| s.parse::<usize>().expect("invalid STYLO_THREADS")) {
- Ok(num) => num,
- _ => cmp::max(num_cpus::get() * 3 / 4, 1),
- }
- };
-}
-
impl PerDocumentStyleData {
/// Create a dummy `PerDocumentStyleData`.
pub fn new(pres_context: RawGeckoPresContextOwned) -> Self {
diff --git a/components/style/lib.rs b/components/style/lib.rs
index 6954c0fe3e7..d94f5436b51 100644
--- a/components/style/lib.rs
+++ b/components/style/lib.rs
@@ -61,7 +61,6 @@ extern crate matches;
#[cfg(feature = "gecko")] extern crate nsstring_vendor as nsstring;
extern crate num_integer;
extern crate num_traits;
-#[cfg(feature = "gecko")] extern crate num_cpus;
extern crate ordered_float;
extern crate owning_ref;
extern crate parking_lot;
diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs
index 711c19a738f..ba01b25ef79 100644
--- a/ports/geckolib/glue.rs
+++ b/ports/geckolib/glue.rs
@@ -8,11 +8,13 @@ use cssparser::Parser;
use cssparser::ToCss as ParserToCss;
use env_logger::LogBuilder;
use euclid::Size2D;
+use num_cpus;
use parking_lot::RwLock;
use rayon;
use selectors::Element;
use servo_url::ServoUrl;
use std::borrow::Cow;
+use std::cmp;
use std::env;
use std::fmt::Write;
use std::mem;
@@ -24,7 +26,7 @@ use style::context::{ThreadLocalStyleContext, ThreadLocalStyleContextCreationInf
use style::data::{ElementData, ElementStyles, RestyleData};
use style::dom::{ShowSubtreeData, TElement, TNode};
use style::error_reporting::StdoutErrorReporter;
-use style::gecko::data::{NUM_THREADS, PerDocumentStyleData, PerDocumentStyleDataImpl};
+use style::gecko::data::{PerDocumentStyleData, PerDocumentStyleDataImpl};
use style::gecko::restyle_damage::GeckoRestyleDamage;
use style::gecko::selector_parser::{SelectorImpl, PseudoElement};
use style::gecko::traversal::RecalcStyleOnly;
@@ -92,6 +94,16 @@ use stylesheet_loader::StylesheetLoader;
*/
lazy_static! {
+ /// The number of layout threads, computed statically.
+ static ref NUM_THREADS: usize = {
+ match env::var("STYLO_THREADS").map(|s| s.parse::<usize>().expect("invalid STYLO_THREADS")) {
+ Ok(num) => num,
+ _ => cmp::max(num_cpus::get() * 3 / 4, 1),
+ }
+ };
+}
+
+lazy_static! {
static ref STYLE_THREAD_POOL: Option<rayon::ThreadPool> = {
let num_threads = *NUM_THREADS;
if num_threads <= 1 {
diff --git a/ports/geckolib/lib.rs b/ports/geckolib/lib.rs
index 9363150acf3..8754021afa5 100644
--- a/ports/geckolib/lib.rs
+++ b/ports/geckolib/lib.rs
@@ -12,6 +12,7 @@ extern crate euclid;
#[macro_use] extern crate lazy_static;
extern crate libc;
#[macro_use] extern crate log;
+extern crate num_cpus;
extern crate parking_lot;
extern crate rayon;
extern crate selectors;