geckolib: use a global thread pool for styling

By having a single thread pool, rather than one per document, we use
less memory.  This addresses
https://bugzilla.mozilla.org/show_bug.cgi?id=1324250.
This commit is contained in:
Nathan Froyd 2017-02-13 12:57:08 -05:00
parent 469ed934e7
commit 3e81f8431e
5 changed files with 22 additions and 25 deletions

View file

@ -14,7 +14,6 @@ use media_queries::Device;
use num_cpus;
use parking_lot::RwLock;
use properties::ComputedValues;
use rayon;
use std::cmp;
use std::collections::HashMap;
use std::env;
@ -48,13 +47,6 @@ pub struct PerDocumentStyleDataImpl {
/// Unused. Will go away when we actually implement transitions and
/// animations properly.
pub expired_animations: Arc<RwLock<HashMap<OpaqueNode, Vec<Animation>>>>,
/// The worker thread pool.
/// FIXME(bholley): This shouldn't be per-document.
pub work_queue: Option<rayon::ThreadPool>,
/// The number of threads of the work queue.
pub num_threads: usize,
}
/// The data itself is an `AtomicRefCell`, which guarantees the proper semantics
@ -86,14 +78,6 @@ impl PerDocumentStyleData {
new_animations_receiver: new_anims_receiver,
running_animations: Arc::new(RwLock::new(HashMap::new())),
expired_animations: Arc::new(RwLock::new(HashMap::new())),
work_queue: if *NUM_THREADS <= 1 {
None
} else {
let configuration =
rayon::Configuration::new().set_num_threads(*NUM_THREADS);
rayon::ThreadPool::new(configuration).ok()
},
num_threads: *NUM_THREADS,
}))
}
@ -141,9 +125,3 @@ unsafe impl HasFFI for PerDocumentStyleData {
}
unsafe impl HasSimpleFFI for PerDocumentStyleData {}
unsafe impl HasBoxFFI for PerDocumentStyleData {}
impl Drop for PerDocumentStyleDataImpl {
fn drop(&mut self) {
let _ = self.work_queue.take();
}
}