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.
This commit is contained in:
Nathan Froyd 2017-02-22 11:22:16 -05:00
parent 3e81f8431e
commit fafcdda16a
6 changed files with 15 additions and 21 deletions

View file

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

View file

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

View file

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