mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
style: Use rayon instead of our custom work queue.
This commit is contained in:
parent
b7eb36fa84
commit
73917cce83
15 changed files with 126 additions and 525 deletions
|
@ -4,15 +4,14 @@
|
|||
|
||||
use animation::Animation;
|
||||
use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut};
|
||||
use context::SharedStyleContext;
|
||||
use dom::OpaqueNode;
|
||||
use euclid::size::TypedSize2D;
|
||||
use gecko_bindings::bindings::RawServoStyleSet;
|
||||
use gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI};
|
||||
use media_queries::{Device, MediaType};
|
||||
use num_cpus;
|
||||
use parallel::WorkQueueData;
|
||||
use parking_lot::RwLock;
|
||||
use rayon;
|
||||
use selector_matching::Stylist;
|
||||
use std::cmp;
|
||||
use std::collections::HashMap;
|
||||
|
@ -21,8 +20,6 @@ use std::sync::Arc;
|
|||
use std::sync::mpsc::{Receiver, Sender, channel};
|
||||
use style_traits::ViewportPx;
|
||||
use stylesheets::Stylesheet;
|
||||
use thread_state;
|
||||
use workqueue::WorkQueue;
|
||||
|
||||
pub struct PerDocumentStyleDataImpl {
|
||||
/// Rule processor.
|
||||
|
@ -41,7 +38,7 @@ pub struct PerDocumentStyleDataImpl {
|
|||
pub expired_animations: Arc<RwLock<HashMap<OpaqueNode, Vec<Animation>>>>,
|
||||
|
||||
// FIXME(bholley): This shouldn't be per-document.
|
||||
pub work_queue: Option<WorkQueue<SharedStyleContext, WorkQueueData>>,
|
||||
pub work_queue: Option<rayon::ThreadPool>,
|
||||
|
||||
pub num_threads: usize,
|
||||
}
|
||||
|
@ -76,7 +73,9 @@ impl PerDocumentStyleData {
|
|||
work_queue: if *NUM_THREADS <= 1 {
|
||||
None
|
||||
} else {
|
||||
WorkQueue::new("StyleWorker", thread_state::LAYOUT, *NUM_THREADS).ok()
|
||||
let configuration =
|
||||
rayon::Configuration::new().set_num_threads(*NUM_THREADS);
|
||||
rayon::ThreadPool::new(configuration).ok()
|
||||
},
|
||||
num_threads: *NUM_THREADS,
|
||||
}))
|
||||
|
@ -112,8 +111,6 @@ unsafe impl HasBoxFFI for PerDocumentStyleData {}
|
|||
|
||||
impl Drop for PerDocumentStyleDataImpl {
|
||||
fn drop(&mut self) {
|
||||
if let Some(ref mut queue) = self.work_queue {
|
||||
queue.shutdown();
|
||||
}
|
||||
let _ = self.work_queue.take();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue