aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/script_thread.rs
diff options
context:
space:
mode:
authorAlan Jeffrey <ajeffrey@mozilla.com>2017-04-03 14:35:57 -0500
committerAlan Jeffrey <ajeffrey@mozilla.com>2017-05-17 09:01:05 -0500
commitaf8436c9be4c69c07265ab1095f89982b48cdd00 (patch)
tree0a4dbfaeb69c7a1741840e94ffb88139317ef295 /components/script/script_thread.rs
parentabb2985ffe96485b58f6b9e5f8b2dd3641d987b7 (diff)
downloadservo-af8436c9be4c69c07265ab1095f89982b48cdd00.tar.gz
servo-af8436c9be4c69c07265ab1095f89982b48cdd00.zip
Implemented Houdini worklets.
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r--components/script/script_thread.rs28
1 files changed, 27 insertions, 1 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index a8b20b6cf98..8a6efa946ad 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -56,6 +56,8 @@ use dom::uievent::UIEvent;
use dom::window::{ReflowReason, Window};
use dom::windowproxy::WindowProxy;
use dom::worker::TrustedWorkerAddress;
+use dom::worklet::WorkletThreadPool;
+use dom::workletglobalscope::WorkletGlobalScopeInit;
use euclid::Rect;
use euclid::point::Point2D;
use hyper::header::{ContentType, HttpDate, LastModified, Headers};
@@ -490,6 +492,9 @@ pub struct ScriptThread {
/// A handle to the webvr thread, if available
webvr_thread: Option<IpcSender<WebVRMsg>>,
+ /// The worklet thread pool
+ worklet_thread_pool: DOMRefCell<Option<Rc<WorkletThreadPool>>>,
+
/// A list of pipelines containing documents that finished loading all their blocking
/// resources during a turn of the event loop.
docs_with_no_blocking_loads: DOMRefCell<HashSet<JS<Document>>>,
@@ -703,6 +708,24 @@ impl ScriptThread {
}))
}
+ pub fn worklet_thread_pool() -> Rc<WorkletThreadPool> {
+ SCRIPT_THREAD_ROOT.with(|root| {
+ let script_thread = unsafe { &*root.get().unwrap() };
+ script_thread.worklet_thread_pool.borrow_mut().get_or_insert_with(|| {
+ let chan = script_thread.chan.0.clone();
+ let init = WorkletGlobalScopeInit {
+ resource_threads: script_thread.resource_threads.clone(),
+ mem_profiler_chan: script_thread.mem_profiler_chan.clone(),
+ time_profiler_chan: script_thread.time_profiler_chan.clone(),
+ devtools_chan: script_thread.devtools_chan.clone(),
+ constellation_chan: script_thread.constellation_chan.clone(),
+ scheduler_chan: script_thread.scheduler_chan.clone(),
+ };
+ Rc::new(WorkletThreadPool::spawn(chan, init))
+ }).clone()
+ })
+ }
+
/// Creates a new script thread.
pub fn new(state: InitialScriptState,
port: Receiver<MainThreadScriptMsg>,
@@ -782,6 +805,8 @@ impl ScriptThread {
webvr_thread: state.webvr_thread,
+ worklet_thread_pool: Default::default(),
+
docs_with_no_blocking_loads: Default::default(),
transitioning_nodes: Default::default(),
@@ -1065,6 +1090,7 @@ impl ScriptThread {
ScriptThreadEventCategory::WebSocketEvent => ProfilerCategory::ScriptWebSocketEvent,
ScriptThreadEventCategory::WebVREvent => ProfilerCategory::ScriptWebVREvent,
ScriptThreadEventCategory::WorkerEvent => ProfilerCategory::ScriptWorkerEvent,
+ ScriptThreadEventCategory::WorkletEvent => ProfilerCategory::ScriptWorkletEvent,
ScriptThreadEventCategory::ServiceWorkerEvent => ProfilerCategory::ScriptServiceWorkerEvent,
ScriptThreadEventCategory::EnterFullscreen => ProfilerCategory::ScriptEnterFullscreen,
ScriptThreadEventCategory::ExitFullscreen => ProfilerCategory::ScriptExitFullscreen,
@@ -1149,7 +1175,7 @@ impl ScriptThread {
// The category of the runnable is ignored by the pattern, however
// it is still respected by profiling (see categorize_msg).
if !runnable.is_cancelled() {
- runnable.handler()
+ runnable.main_thread_handler(self)
}
}
MainThreadScriptMsg::Common(CommonScriptMsg::CollectReports(reports_chan)) =>