mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ use gecko_bindings::bindings::Gecko_StoreStyleDifference;
|
|||
use gecko_bindings::structs;
|
||||
use gecko_bindings::structs::{NODE_HAS_DIRTY_DESCENDANTS_FOR_SERVO, NODE_IS_DIRTY_FOR_SERVO};
|
||||
use gecko_bindings::structs::{nsIAtom, nsIContent, nsStyleContext};
|
||||
use libc::uintptr_t;
|
||||
use parking_lot::RwLock;
|
||||
use parser::ParserContextExtraData;
|
||||
use properties::{ComputedValues, parse_style_attribute};
|
||||
|
@ -114,7 +113,7 @@ impl<'ln> TNode for GeckoNode<'ln> {
|
|||
}
|
||||
|
||||
fn opaque(&self) -> OpaqueNode {
|
||||
let ptr: uintptr_t = self.0 as *const _ as uintptr_t;
|
||||
let ptr: usize = self.0 as *const _ as usize;
|
||||
OpaqueNode(ptr)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue