From 1f02c4ebbb7d5ea49051f4391f1418f20c15d7a9 Mon Sep 17 00:00:00 2001 From: "rohan.prinja" Date: Sat, 14 Nov 2015 05:07:55 +0900 Subject: [PATCH] task -> thread --- ...s_paint_task.rs => canvas_paint_thread.rs} | 24 +- components/canvas/lib.rs | 4 +- ...gl_paint_task.rs => webgl_paint_thread.rs} | 24 +- components/compositing/compositor.rs | 24 +- components/compositing/compositor_layer.rs | 12 +- ...ompositor_task.rs => compositor_thread.rs} | 24 +- components/compositing/constellation.rs | 172 ++++---- components/compositing/headless.rs | 8 +- components/compositing/lib.rs | 4 +- components/compositing/pipeline.rs | 102 ++--- components/compositing/scrolling.rs | 4 +- components/compositing/surface_map.rs | 2 +- components/compositing/timer_scheduler.rs | 6 +- components/compositing/windowing.rs | 4 +- components/devtools/actors/timeline.rs | 4 +- components/devtools/lib.rs | 4 +- components/devtools_traits/lib.rs | 8 +- components/gfx/display_list/mod.rs | 4 +- ...ont_cache_task.rs => font_cache_thread.rs} | 30 +- components/gfx/font_context.rs | 24 +- components/gfx/lib.rs | 4 +- .../gfx/{paint_task.rs => paint_thread.rs} | 74 ++-- components/gfx_traits/paint_listener.rs | 2 +- components/layout/block.rs | 2 +- components/layout/context.rs | 28 +- components/layout/display_list_builder.rs | 6 +- components/layout/fragment.rs | 4 +- components/layout/layout_debug.rs | 8 +- .../{layout_task.rs => layout_thread.rs} | 176 ++++---- components/layout/lib.rs | 2 +- components/layout/query.rs | 6 +- components/layout/traversal.rs | 8 +- components/layout/wrapper.rs | 2 +- components/layout_traits/lib.rs | 14 +- components/msg/constellation_msg.rs | 4 +- components/net/about_loader.rs | 2 +- components/net/data_loader.rs | 6 +- components/net/fetch/cors_cache.rs | 66 +-- components/net/fetch/request.rs | 4 +- components/net/file_loader.rs | 6 +- components/net/http_loader.rs | 4 +- ...ge_cache_task.rs => image_cache_thread.rs} | 44 +- components/net/lib.rs | 6 +- .../{resource_task.rs => resource_thread.rs} | 30 +- .../{storage_task.rs => storage_thread.rs} | 32 +- components/net/websocket_loader.rs | 2 +- ...ge_cache_task.rs => image_cache_thread.rs} | 20 +- components/net_traits/lib.rs | 24 +- .../{storage_task.rs => storage_thread.rs} | 8 +- .../plugins/lints/unrooted_must_root.rs | 2 +- components/profile/mem.rs | 2 +- components/profile/time.rs | 2 +- components/profile_traits/mem.rs | 2 +- components/script/cors.rs | 6 +- components/script/devtools.rs | 2 +- components/script/document_loader.rs | 16 +- components/script/dom/bindings/cell.rs | 20 +- components/script/dom/bindings/global.rs | 42 +- components/script/dom/bindings/js.rs | 60 +-- components/script/dom/bindings/refcounted.rs | 20 +- components/script/dom/bindings/trace.rs | 8 +- .../script/dom/canvasrenderingcontext2d.rs | 6 +- components/script/dom/closeevent.rs | 2 +- .../script/dom/dedicatedworkerglobalscope.rs | 21 +- components/script/dom/document.rs | 8 +- components/script/dom/filereader.rs | 24 +- components/script/dom/htmlcanvaselement.rs | 4 +- components/script/dom/htmlformelement.rs | 2 +- components/script/dom/htmlimageelement.rs | 14 +- components/script/dom/htmlinputelement.rs | 6 +- components/script/dom/htmllinkelement.rs | 2 +- components/script/dom/htmlscriptelement.rs | 10 +- components/script/dom/mod.rs | 4 +- components/script/dom/node.rs | 10 +- components/script/dom/servohtmlparser.rs | 6 +- components/script/dom/servoxmlparser.rs | 4 +- components/script/dom/storage.rs | 36 +- .../script/dom/webglrenderingcontext.rs | 6 +- components/script/dom/webglshader.rs | 4 +- components/script/dom/websocket.rs | 38 +- components/script/dom/window.rs | 118 ++--- components/script/dom/worker.rs | 12 +- components/script/dom/workerglobalscope.rs | 16 +- components/script/dom/xmlhttprequest.rs | 28 +- components/script/layout_interface.rs | 28 +- components/script/lib.rs | 4 +- components/script/network_listener.rs | 4 +- .../{script_task.rs => script_thread.rs} | 404 +++++++++--------- components/script/timers.rs | 2 +- components/script/webdriver_handlers.rs | 2 +- components/script_traits/lib.rs | 68 +-- components/script_traits/script_msg.rs | 8 +- components/servo/lib.rs | 44 +- components/servo/main.rs | 2 +- components/style/traversal.rs | 16 +- components/util/lib.rs | 6 +- components/util/opts.rs | 8 +- components/util/{task.rs => thread.rs} | 8 +- .../util/{task_state.rs => thread_state.rs} | 40 +- .../util/{taskpool.rs => threadpool.rs} | 24 +- components/util/tid.rs | 2 +- components/util/workqueue.rs | 12 +- components/webdriver_server/lib.rs | 2 +- ports/cef/browser.rs | 4 +- ports/cef/interfaces/cef_browser.rs | 10 +- ports/cef/interfaces/cef_task.rs | 5 +- ports/cef/task.rs | 1 - ports/cef/window.rs | 6 +- ports/glutin/window.rs | 10 +- ports/gonk/src/window.rs | 6 +- support/rust-task_info/src/task_basic_info.rs | 1 - ...ont_cache_task.rs => font_cache_thread.rs} | 6 +- tests/unit/gfx/lib.rs | 2 +- tests/unit/net/data_loader.rs | 2 +- tests/unit/net/http_loader.rs | 4 +- tests/unit/net/lib.rs | 2 +- .../{resource_task.rs => resource_thread.rs} | 24 +- tests/unit/util/lib.rs | 2 +- tests/unit/util/{task.rs => thread.rs} | 2 +- 119 files changed, 1209 insertions(+), 1207 deletions(-) rename components/canvas/{canvas_paint_task.rs => canvas_paint_thread.rs} (98%) rename components/canvas/{webgl_paint_task.rs => webgl_paint_thread.rs} (97%) rename components/compositing/{compositor_task.rs => compositor_thread.rs} (94%) rename components/gfx/{font_cache_task.rs => font_cache_thread.rs} (95%) rename components/gfx/{paint_task.rs => paint_thread.rs} (94%) rename components/layout/{layout_task.rs => layout_thread.rs} (92%) rename components/net/{image_cache_task.rs => image_cache_thread.rs} (93%) rename components/net/{resource_task.rs => resource_thread.rs} (95%) rename components/net/{storage_task.rs => storage_thread.rs} (89%) rename components/net_traits/{image_cache_task.rs => image_cache_thread.rs} (92%) rename components/net_traits/{storage_task.rs => storage_thread.rs} (91%) rename components/script/{script_task.rs => script_thread.rs} (85%) rename components/util/{task.rs => thread.rs} (90%) rename components/util/{task_state.rs => thread_state.rs} (67%) rename components/util/{taskpool.rs => threadpool.rs} (68%) rename tests/unit/gfx/{font_cache_task.rs => font_cache_thread.rs} (77%) rename tests/unit/net/{resource_task.rs => resource_thread.rs} (91%) rename tests/unit/util/{task.rs => thread.rs} (91%) diff --git a/components/canvas/canvas_paint_task.rs b/components/canvas/canvas_paint_thread.rs similarity index 98% rename from components/canvas/canvas_paint_task.rs rename to components/canvas/canvas_paint_thread.rs index bf2c00f989d..92b3863cdf9 100644 --- a/components/canvas/canvas_paint_task.rs +++ b/components/canvas/canvas_paint_thread.rs @@ -22,10 +22,10 @@ use std::borrow::ToOwned; use std::mem; use std::sync::mpsc::{Sender, channel}; use util::opts; -use util::task::spawn_named; +use util::thread::spawn_named; use util::vec::byte_swap; -impl<'a> CanvasPaintTask<'a> { +impl<'a> CanvasPaintThread<'a> { /// It reads image data from the canvas /// canvas_size: The size of the canvas we're reading from /// read_rect: The area of the canvas we want to read from @@ -57,7 +57,7 @@ impl<'a> CanvasPaintTask<'a> { } } -pub struct CanvasPaintTask<'a> { +pub struct CanvasPaintThread<'a> { drawtarget: DrawTarget, /// TODO(pcwalton): Support multiple paths. path_builder: PathBuilder, @@ -101,11 +101,11 @@ impl<'a> CanvasPaintState<'a> { } } -impl<'a> CanvasPaintTask<'a> { - fn new(size: Size2D) -> CanvasPaintTask<'a> { - let draw_target = CanvasPaintTask::create(size); +impl<'a> CanvasPaintThread<'a> { + fn new(size: Size2D) -> CanvasPaintThread<'a> { + let draw_target = CanvasPaintThread::create(size); let path_builder = draw_target.create_path_builder(); - CanvasPaintTask { + CanvasPaintThread { drawtarget: draw_target, path_builder: path_builder, state: CanvasPaintState::new(), @@ -113,7 +113,7 @@ impl<'a> CanvasPaintTask<'a> { } } - /// Creates a new `CanvasPaintTask` and returns the out-of-process sender and the in-process + /// Creates a new `CanvasPaintThread` and returns the out-of-process sender and the in-process /// sender for it. pub fn start(size: Size2D) -> (IpcSender, Sender) { // TODO(pcwalton): Ask the pipeline to create this for us instead of spawning it directly. @@ -121,8 +121,8 @@ impl<'a> CanvasPaintTask<'a> { let (out_of_process_chan, out_of_process_port) = ipc::channel::().unwrap(); let (in_process_chan, in_process_port) = channel(); ROUTER.route_ipc_receiver_to_mpsc_sender(out_of_process_port, in_process_chan.clone()); - spawn_named("CanvasTask".to_owned(), move || { - let mut painter = CanvasPaintTask::new(size); + spawn_named("CanvasThread".to_owned(), move || { + let mut painter = CanvasPaintThread::new(size); loop { let msg = in_process_port.recv(); match msg.unwrap() { @@ -202,7 +202,7 @@ impl<'a> CanvasPaintTask<'a> { } } } - CanvasMsg::WebGL(_) => panic!("Wrong message sent to Canvas2D task"), + CanvasMsg::WebGL(_) => panic!("Wrong message sent to Canvas2D thread"), } } }); @@ -516,7 +516,7 @@ impl<'a> CanvasPaintTask<'a> { } fn recreate(&mut self, size: Size2D) { - self.drawtarget = CanvasPaintTask::create(size); + self.drawtarget = CanvasPaintThread::create(size); } fn send_pixel_contents(&mut self, chan: IpcSender) { diff --git a/components/canvas/lib.rs b/components/canvas/lib.rs index 87b61010278..13827b70459 100644 --- a/components/canvas/lib.rs +++ b/components/canvas/lib.rs @@ -22,6 +22,6 @@ extern crate num; extern crate offscreen_gl_context; extern crate util; -pub mod canvas_paint_task; +pub mod canvas_paint_thread; mod premultiplytable; -pub mod webgl_paint_task; +pub mod webgl_paint_thread; diff --git a/components/canvas/webgl_paint_task.rs b/components/canvas/webgl_paint_thread.rs similarity index 97% rename from components/canvas/webgl_paint_task.rs rename to components/canvas/webgl_paint_thread.rs index 8bef975d41a..7558bc765cc 100644 --- a/components/canvas/webgl_paint_task.rs +++ b/components/canvas/webgl_paint_thread.rs @@ -14,17 +14,17 @@ use layers::platform::surface::NativeSurface; use offscreen_gl_context::{ColorAttachmentType, GLContext, GLContextAttributes, NativeGLContext}; use std::borrow::ToOwned; use std::sync::mpsc::{Sender, channel}; -use util::task::spawn_named; +use util::thread::spawn_named; use util::vec::byte_swap; -pub struct WebGLPaintTask { +pub struct WebGLPaintThread { size: Size2D, original_context_size: Size2D, gl_context: GLContext, } -impl WebGLPaintTask { - fn new(size: Size2D, attrs: GLContextAttributes) -> Result { +impl WebGLPaintThread { + fn new(size: Size2D, attrs: GLContextAttributes) -> Result { let context = try!(GLContext::new(size, attrs, ColorAttachmentType::Texture, None)); // NOTE: As of right now this is always equal to the size parameter, @@ -32,7 +32,7 @@ impl WebGLPaintTask { // the requested size, tries with the nearest powers of two, for example. let real_size = context.borrow_draw_buffer().unwrap().size(); - Ok(WebGLPaintTask { + Ok(WebGLPaintThread { size: real_size, original_context_size: real_size, gl_context: context @@ -183,7 +183,7 @@ impl WebGLPaintTask { assert!(gl::get_error() == gl::NO_ERROR); } - /// Creates a new `WebGLPaintTask` and returns the out-of-process sender and the in-process + /// Creates a new `WebGLPaintThread` and returns the out-of-process sender and the in-process /// sender for it. pub fn start(size: Size2D, attrs: GLContextAttributes) -> Result<(IpcSender, Sender), &'static str> { @@ -191,11 +191,11 @@ impl WebGLPaintTask { let (in_process_chan, in_process_port) = channel(); let (result_chan, result_port) = channel(); ROUTER.route_ipc_receiver_to_mpsc_sender(out_of_process_port, in_process_chan.clone()); - spawn_named("WebGLTask".to_owned(), move || { - let mut painter = match WebGLPaintTask::new(size, attrs) { - Ok(task) => { + spawn_named("WebGLThread".to_owned(), move || { + let mut painter = match WebGLPaintThread::new(size, attrs) { + Ok(thread) => { result_chan.send(Ok(())).unwrap(); - task + thread }, Err(e) => { result_chan.send(Err(e)).unwrap(); @@ -225,7 +225,7 @@ impl WebGLPaintTask { painter.send_native_surface(chan), } } - CanvasMsg::Canvas2d(_) => panic!("Wrong message sent to WebGLTask"), + CanvasMsg::Canvas2d(_) => panic!("Wrong message sent to WebGLThread"), } } }); @@ -279,7 +279,7 @@ impl WebGLPaintTask { } fn create_texture(&self, chan: IpcSender>>) { - let texture = gl::gen_textures(1)[0]; + let texture = gl::gen_framebuffers(1)[0]; let texture = if texture == 0 { None } else { diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index ce4e379ba4e..95b04c4a093 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -5,15 +5,15 @@ use CompositorMsg as ConstellationMsg; use app_units::Au; use compositor_layer::{CompositorData, CompositorLayer, RcCompositorLayer, WantsScrollEventsFlag}; -use compositor_task::{CompositorEventListener, CompositorProxy}; -use compositor_task::{CompositorReceiver, InitialCompositorState, Msg}; +use compositor_thread::{CompositorEventListener, CompositorProxy}; +use compositor_thread::{CompositorReceiver, InitialCompositorState, Msg}; use constellation::SendableFrameTree; use euclid::point::TypedPoint2D; use euclid::rect::TypedRect; use euclid::scale_factor::ScaleFactor; use euclid::size::TypedSize2D; use euclid::{Matrix4, Point2D, Rect, Size2D}; -use gfx::paint_task::{ChromeToPaintMsg, PaintRequest}; +use gfx::paint_thread::{ChromeToPaintMsg, PaintRequest}; use gfx_traits::{color, LayerId, LayerKind, LayerProperties, ScrollPolicy}; use gleam::gl; use gleam::gl::types::{GLint, GLsizei}; @@ -375,13 +375,13 @@ impl IOCompositor { pub fn finish_shutting_down(&mut self) { debug!("Compositor received message that constellation shutdown is complete"); - // Clear out the compositor layers so that painting tasks can destroy the buffers. + // Clear out the compositor layers so that painting threads can destroy the buffers. if let Some(ref root_layer) = self.scene.root { root_layer.forget_all_tiles(); } // Drain compositor port, sometimes messages contain channels that are blocking - // another task from finishing (i.e. SetFrameTree). + // another thread from finishing (i.e. SetFrameTree). while self.port.try_recv_compositor_msg().is_some() {} // Tell the profiler, memory profiler, and scrolling timer to shut down. @@ -546,7 +546,7 @@ impl IOCompositor { reply.send(img).unwrap(); } - (Msg::PaintTaskExited(pipeline_id), ShutdownState::NotShuttingDown) => { + (Msg::PaintThreadExited(pipeline_id), ShutdownState::NotShuttingDown) => { self.remove_pipeline_root_layer(pipeline_id); } @@ -580,7 +580,7 @@ impl IOCompositor { } (Msg::CollectMemoryReports(reports_chan), ShutdownState::NotShuttingDown) => { - let name = "compositor-task"; + let name = "compositor-thread"; // These are both `ExplicitUnknownLocationSize` because the memory might be in the // GPU or on the heap. let reports = vec![mem::Report { @@ -975,7 +975,7 @@ impl IOCompositor { epoch: Epoch, frame_tree_id: FrameTreeId) { // If the frame tree id has changed since this paint request was sent, - // reject the buffers and send them back to the paint task. If this isn't handled + // reject the buffers and send them back to the paint thread. If this isn't handled // correctly, the content_age in the tile grid can get out of sync when iframes are // loaded and the frame tree changes. This can result in the compositor thinking it // has already drawn the most recently painted buffer, and missing a frame. @@ -1470,7 +1470,7 @@ impl IOCompositor { } }; - // All the BufferRequests are in layer/device coordinates, but the paint task + // All the BufferRequests are in layer/device coordinates, but the paint thread // wants to know the page coordinates. We scale them before sending them. for request in &mut layer_requests { request.page_rect = request.page_rect / scale.get(); @@ -1568,7 +1568,7 @@ impl IOCompositor { // If a layer has sent a request for the current epoch, but it hasn't // arrived yet then this layer is waiting for a paint message. // - // Also don't check the root layer, because the paint task won't paint + // Also don't check the root layer, because the paint thread won't paint // anything for it after first layout. if layer_data.id != LayerId::null() && layer_data.requested_epoch == current_epoch && @@ -1587,7 +1587,7 @@ impl IOCompositor { /// Query the constellation to see if the current compositor /// output matches the current frame tree output, and if the - /// associated script tasks are idle. + /// associated script threads are idle. fn is_ready_to_paint_image_output(&mut self) -> Result<(), NotReadyToPaint> { match self.ready_to_save_state { ReadyState::Unknown => { @@ -2001,7 +2001,7 @@ fn find_layer_with_pipeline_and_layer_id_for_layer(layer: Rc CompositorEventListener for IOCompositor where Window: WindowMethods { fn handle_events(&mut self, messages: Vec) -> bool { - // Check for new messages coming from the other tasks in the system. + // Check for new messages coming from the other threads in the system. while let Some(msg) = self.port.try_recv_compositor_msg() { if !self.handle_browser_message(msg) { break diff --git a/components/compositing/compositor_layer.rs b/components/compositing/compositor_layer.rs index d5fd0cb04c9..1f2cff4c144 100644 --- a/components/compositing/compositor_layer.rs +++ b/components/compositing/compositor_layer.rs @@ -97,17 +97,17 @@ pub trait CompositorLayer { /// Removes the root layer (and any children) for a given pipeline from the /// compositor. Buffers that the compositor is holding are returned to the - /// owning paint task. + /// owning paint thread. fn remove_root_layer_with_pipeline_id(&self, compositor: &mut IOCompositor, pipeline_id: PipelineId) where Window: WindowMethods; /// Destroys all tiles of all layers, including children, *without* sending them back to the - /// painter. You must call this only when the paint task is destined to be going down; + /// painter. You must call this only when the paint thread is destined to be going down; /// otherwise, you will leak tiles. /// - /// This is used during shutdown, when we know the paint task is going away. + /// This is used during shutdown, when we know the paint thread is going away. fn forget_all_tiles(&self); /// Move the layer's descendants that don't want scroll events and scroll by a relative @@ -280,7 +280,7 @@ impl CompositorLayer for Layer { match index { Some(index) => { - // Remove the root layer, and return buffers to the paint task + // Remove the root layer, and return buffers to the paint thread let child = self.children().remove(index); child.clear_all_tiles(compositor); } @@ -294,10 +294,10 @@ impl CompositorLayer for Layer { } /// Destroys all tiles of all layers, including children, *without* sending them back to the - /// painter. You must call this only when the paint task is destined to be going down; + /// painter. You must call this only when the paint thread is destined to be going down; /// otherwise, you will leak tiles. /// - /// This is used during shutdown, when we know the paint task is going away. + /// This is used during shutdown, when we know the paint thread is going away. fn forget_all_tiles(&self) { let tiles = self.collect_buffers(); for tile in tiles { diff --git a/components/compositing/compositor_task.rs b/components/compositing/compositor_thread.rs similarity index 94% rename from components/compositing/compositor_task.rs rename to components/compositing/compositor_thread.rs index 293312b3778..dfc01d1635e 100644 --- a/components/compositing/compositor_task.rs +++ b/components/compositing/compositor_thread.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -//! Communication with the compositor task. +//! Communication with the compositor thread. use CompositorMsg as ConstellationMsg; use compositor; @@ -107,10 +107,10 @@ impl PaintListener for Box { fn native_display(&mut self) -> Option { let (chan, port) = channel(); self.send(Msg::GetNativeDisplay(chan)); - // If the compositor is shutting down when a paint task + // If the compositor is shutting down when a paint thread // is being created, the compositor won't respond to // this message, resulting in an eventual panic. Instead, - // just return None in this case, since the paint task + // just return None in this case, since the paint thread // will exit shortly and never actually be requested // to paint buffers by the compositor. port.recv().unwrap_or(None) @@ -146,12 +146,12 @@ impl PaintListener for Box { self.send(Msg::InitializeLayersForPipeline(pipeline_id, epoch, properties)); } - fn notify_paint_task_exiting(&mut self, pipeline_id: PipelineId) { - self.send(Msg::PaintTaskExited(pipeline_id)) + fn notify_paint_thread_exiting(&mut self, pipeline_id: PipelineId) { + self.send(Msg::PaintThreadExited(pipeline_id)) } } -/// Messages from the painting task and the constellation task to the compositor task. +/// Messages from the painting thread and the constellation thread to the compositor thread. pub enum Msg { /// Requests that the compositor shut down. Exit(IpcSender<()>), @@ -199,8 +199,8 @@ pub enum Msg { SetCursor(Cursor), /// Composite to a PNG file and return the Image over a passed channel. CreatePng(IpcSender>), - /// Informs the compositor that the paint task for the given pipeline has exited. - PaintTaskExited(PipelineId), + /// Informs the compositor that the paint thread for the given pipeline has exited. + PaintThreadExited(PipelineId), /// Alerts the compositor that the viewport has been constrained in some manner ViewportConstrained(PipelineId, ViewportConstraints), /// A reply to the compositor asking if the output image is stable. @@ -209,7 +209,7 @@ pub enum Msg { NewFavicon(Url), /// tag finished parsing HeadParsed, - /// Signal that the paint task ignored the paint requests that carried + /// Signal that the paint thread ignored the paint requests that carried /// these native surfaces, so that they can be re-added to the surface cache. ReturnUnusedNativeSurfaces(Vec), /// Collect memory reports and send them back to the given mem::ReportsChan. @@ -247,7 +247,7 @@ impl Debug for Msg { Msg::TouchEventProcessed(..) => write!(f, "TouchEventProcessed"), Msg::SetCursor(..) => write!(f, "SetCursor"), Msg::CreatePng(..) => write!(f, "CreatePng"), - Msg::PaintTaskExited(..) => write!(f, "PaintTaskExited"), + Msg::PaintThreadExited(..) => write!(f, "PaintThreadExited"), Msg::ViewportConstrained(..) => write!(f, "ViewportConstrained"), Msg::IsReadyToSaveImageReply(..) => write!(f, "IsReadyToSaveImageReply"), Msg::NewFavicon(..) => write!(f, "NewFavicon"), @@ -263,9 +263,9 @@ impl Debug for Msg { } } -pub struct CompositorTask; +pub struct CompositorThread; -impl CompositorTask { +impl CompositorThread { pub fn create(window: Option>, state: InitialCompositorState) -> Box diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs index 426138cf313..f590b845d2d 100644 --- a/components/compositing/constellation.rs +++ b/components/compositing/constellation.rs @@ -6,26 +6,26 @@ //! //! The primary duty of a `Constellation` is to mediate between the //! graphics compositor and the many `Pipeline`s in the browser's -//! navigation context, each `Pipeline` encompassing a `ScriptTask`, -//! `LayoutTask`, and `PaintTask`. +//! navigation context, each `Pipeline` encompassing a `ScriptThread`, +//! `LayoutThread`, and `PaintThread`. use CompositorMsg as FromCompositorMsg; -use canvas::canvas_paint_task::CanvasPaintTask; -use canvas::webgl_paint_task::WebGLPaintTask; +use canvas::canvas_paint_thread::CanvasPaintThread; +use canvas::webgl_paint_thread::WebGLPaintThread; use canvas_traits::CanvasMsg; use clipboard::ClipboardContext; -use compositor_task::CompositorProxy; -use compositor_task::Msg as ToCompositorMsg; +use compositor_thread::CompositorProxy; +use compositor_thread::Msg as ToCompositorMsg; use devtools_traits::{ChromeToDevtoolsControlMsg, DevtoolsControlMsg}; use euclid::scale_factor::ScaleFactor; use euclid::size::{Size2D, TypedSize2D}; use gaol; use gaol::sandbox::{self, Sandbox, SandboxMethods}; -use gfx::font_cache_task::FontCacheTask; +use gfx::font_cache_thread::FontCacheThread; use gfx_traits::PaintMsg as FromPaintMsg; use ipc_channel::ipc::{self, IpcOneShotServer, IpcSender}; use ipc_channel::router::ROUTER; -use layout_traits::{LayoutControlChan, LayoutTaskFactory}; +use layout_traits::{LayoutControlChan, LayoutThreadFactory}; use msg::compositor_msg::Epoch; use msg::constellation_msg::AnimationState; use msg::constellation_msg::WebDriverCommandMsg; @@ -36,16 +36,16 @@ use msg::constellation_msg::{PipelineNamespace, PipelineNamespaceId}; use msg::constellation_msg::{SubpageId, WindowSizeData}; use msg::constellation_msg::{self, ConstellationChan, Failure}; use msg::webdriver_msg; -use net_traits::image_cache_task::ImageCacheTask; -use net_traits::storage_task::{StorageTask, StorageTaskMsg}; -use net_traits::{self, ResourceTask}; +use net_traits::image_cache_thread::ImageCacheThread; +use net_traits::storage_thread::{StorageThread, StorageThreadMsg}; +use net_traits::{self, ResourceThread}; use offscreen_gl_context::GLContextAttributes; use pipeline::{CompositionPipeline, InitialPipelineState, Pipeline, UnprivilegedPipelineContent}; use profile_traits::mem; use profile_traits::time; use sandboxing; use script_traits::{CompositorEvent, ConstellationControlMsg, LayoutControlMsg}; -use script_traits::{LayoutMsg as FromLayoutMsg, ScriptMsg as FromScriptMsg, ScriptTaskFactory}; +use script_traits::{LayoutMsg as FromLayoutMsg, ScriptMsg as FromScriptMsg, ScriptThreadFactory}; use script_traits::{TimerEventRequest}; use std::borrow::ToOwned; use std::collections::HashMap; @@ -60,7 +60,7 @@ use timer_scheduler::TimerScheduler; use url::Url; use util::cursor::Cursor; use util::geometry::PagePx; -use util::task::spawn_named; +use util::thread::spawn_named; use util::{opts, prefs}; #[derive(Debug, PartialEq)] @@ -76,9 +76,9 @@ enum ReadyToSave { /// Maintains the pipelines and navigation context and grants permission to composite. /// -/// It is parameterized over a `LayoutTaskFactory` and a -/// `ScriptTaskFactory` (which in practice are implemented by -/// `LayoutTask` in the `layout` crate, and `ScriptTask` in +/// It is parameterized over a `LayoutThreadFactory` and a +/// `ScriptThreadFactory` (which in practice are implemented by +/// `LayoutThread` in the `layout` crate, and `ScriptThread` in /// the `script` crate). pub struct Constellation { /// A channel through which script messages can be sent to this object. @@ -87,10 +87,10 @@ pub struct Constellation { /// A channel through which compositor messages can be sent to this object. pub compositor_sender: Sender, - /// A channel through which layout task messages can be sent to this object. + /// A channel through which layout thread messages can be sent to this object. pub layout_sender: ConstellationChan, - /// A channel through which paint task messages can be sent to this object. + /// A channel through which paint thread messages can be sent to this object. pub painter_sender: ConstellationChan, /// Receives messages from scripts. @@ -99,27 +99,27 @@ pub struct Constellation { /// Receives messages from the compositor pub compositor_receiver: Receiver, - /// Receives messages from the layout task + /// Receives messages from the layout thread pub layout_receiver: Receiver, - /// Receives messages from paint task. + /// Receives messages from paint thread. pub painter_receiver: Receiver, /// A channel (the implementation of which is port-specific) through which messages can be sent /// to the compositor. pub compositor_proxy: Box, - /// A channel through which messages can be sent to the resource task. - pub resource_task: ResourceTask, + /// A channel through which messages can be sent to the resource thread. + pub resource_thread: ResourceThread, - /// A channel through which messages can be sent to the image cache task. - pub image_cache_task: ImageCacheTask, + /// A channel through which messages can be sent to the image cache thread. + pub image_cache_thread: ImageCacheThread, /// A channel through which messages can be sent to the developer tools. devtools_chan: Option>, - /// A channel through which messages can be sent to the storage task. - storage_task: StorageTask, + /// A channel through which messages can be sent to the storage thread. + storage_thread: StorageThread, /// A list of all the pipelines. (See the `pipeline` module for more details.) pipelines: HashMap, @@ -134,7 +134,7 @@ pub struct Constellation { subpage_map: HashMap<(PipelineId, SubpageId), PipelineId>, /// A channel through which messages can be sent to the font cache. - font_cache_task: FontCacheTask, + font_cache_thread: FontCacheThread, /// ID of the root frame. root_frame_id: Option, @@ -167,11 +167,11 @@ pub struct Constellation { /// Bits of state used to interact with the webdriver implementation webdriver: WebDriverData, - /// A list of in-process senders to `CanvasPaintTask`s. - canvas_paint_tasks: Vec>, + /// A list of in-process senders to `CanvasPaintThread`s. + canvas_paint_threads: Vec>, - /// A list of in-process senders to `WebGLPaintTask`s. - webgl_paint_tasks: Vec>, + /// A list of in-process senders to `WebGLPaintThread`s. + webgl_paint_threads: Vec>, scheduler_chan: IpcSender, @@ -188,14 +188,14 @@ pub struct InitialConstellationState { pub compositor_proxy: Box, /// A channel to the developer tools, if applicable. pub devtools_chan: Option>, - /// A channel to the image cache task. - pub image_cache_task: ImageCacheTask, - /// A channel to the font cache task. - pub font_cache_task: FontCacheTask, - /// A channel to the resource task. - pub resource_task: ResourceTask, - /// A channel to the storage task. - pub storage_task: StorageTask, + /// A channel to the image cache thread. + pub image_cache_thread: ImageCacheThread, + /// A channel to the font cache thread. + pub font_cache_thread: FontCacheThread, + /// A channel to the resource thread. + pub resource_thread: ResourceThread, + /// A channel to the storage thread. + pub storage_thread: StorageThread, /// A channel to the time profiler thread. pub time_profiler_chan: time::ProfilerChan, /// A channel to the memory profiler thread. @@ -288,7 +288,7 @@ enum ChildProcess { Unsandboxed(process::Child), } -impl Constellation { +impl Constellation { pub fn start(state: InitialConstellationState) -> Sender { let (ipc_script_receiver, ipc_script_sender) = ConstellationChan::::new(); let script_receiver = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_script_receiver); @@ -310,10 +310,10 @@ impl Constellation { painter_receiver: painter_receiver, compositor_proxy: state.compositor_proxy, devtools_chan: state.devtools_chan, - resource_task: state.resource_task, - image_cache_task: state.image_cache_task, - font_cache_task: state.font_cache_task, - storage_task: state.storage_task, + resource_thread: state.resource_thread, + image_cache_thread: state.image_cache_thread, + font_cache_thread: state.font_cache_thread, + storage_thread: state.storage_thread, pipelines: HashMap::new(), frames: HashMap::new(), pipeline_to_frame_map: HashMap::new(), @@ -340,8 +340,8 @@ impl Constellation { None }, webdriver: WebDriverData::new(), - canvas_paint_tasks: Vec::new(), - webgl_paint_tasks: Vec::new(), + canvas_paint_threads: Vec::new(), + webgl_paint_threads: Vec::new(), scheduler_chan: TimerScheduler::start(), child_processes: Vec::new(), document_states: HashMap::new(), @@ -386,10 +386,10 @@ impl Constellation { scheduler_chan: self.scheduler_chan.clone(), compositor_proxy: self.compositor_proxy.clone_compositor_proxy(), devtools_chan: self.devtools_chan.clone(), - image_cache_task: self.image_cache_task.clone(), - font_cache_task: self.font_cache_task.clone(), - resource_task: self.resource_task.clone(), - storage_task: self.storage_task.clone(), + image_cache_thread: self.image_cache_thread.clone(), + font_cache_thread: self.font_cache_thread.clone(), + resource_thread: self.resource_thread.clone(), + storage_thread: self.storage_thread.clone(), time_profiler_chan: self.time_profiler_chan.clone(), mem_profiler_chan: self.mem_profiler_chan.clone(), window_size: initial_window_size, @@ -400,7 +400,7 @@ impl Constellation { }); if spawning_paint_only { - privileged_pipeline_content.start_paint_task(); + privileged_pipeline_content.start_paint_thread(); } else { privileged_pipeline_content.start_all(); @@ -681,13 +681,13 @@ impl Constellation { debug!("constellation got head parsed message"); self.compositor_proxy.send(ToCompositorMsg::HeadParsed); } - Request::Script(FromScriptMsg::CreateCanvasPaintTask(size, sender)) => { - debug!("constellation got create-canvas-paint-task message"); - self.handle_create_canvas_paint_task_msg(&size, sender) + Request::Script(FromScriptMsg::CreateCanvasPaintThread(size, sender)) => { + debug!("constellation got create-canvas-paint-thread message"); + self.handle_create_canvas_paint_thread_msg(&size, sender) } - Request::Script(FromScriptMsg::CreateWebGLPaintTask(size, attributes, sender)) => { - debug!("constellation got create-WebGL-paint-task message"); - self.handle_create_webgl_paint_task_msg(&size, attributes, sender) + Request::Script(FromScriptMsg::CreateWebGLPaintThread(size, attributes, sender)) => { + debug!("constellation got create-WebGL-paint-thread message"); + self.handle_create_webgl_paint_thread_msg(&size, attributes, sender) } Request::Script(FromScriptMsg::NodeStatus(message)) => { debug!("constellation got NodeStatus message"); @@ -699,7 +699,7 @@ impl Constellation { } - // Messages from layout task + // Messages from layout thread Request::Layout(FromLayoutMsg::ChangeRunningAnimationsState(pipeline_id, animation_state)) => { self.handle_change_running_animations_state(pipeline_id, animation_state) @@ -717,7 +717,7 @@ impl Constellation { } - // Messages from paint task + // Messages from paint thread // Notification that painting has finished and is requesting permission to paint. @@ -734,14 +734,14 @@ impl Constellation { for (_id, ref pipeline) in &self.pipelines { pipeline.exit(); } - self.image_cache_task.exit(); - self.resource_task.send(net_traits::ControlMsg::Exit).unwrap(); + self.image_cache_thread.exit(); + self.resource_thread.send(net_traits::ControlMsg::Exit).unwrap(); self.devtools_chan.as_ref().map(|chan| { chan.send(DevtoolsControlMsg::FromChrome( ChromeToDevtoolsControlMsg::ServerExitMsg)).unwrap(); }); - self.storage_task.send(StorageTaskMsg::Exit).unwrap(); - self.font_cache_task.exit(); + self.storage_thread.send(StorageThreadMsg::Exit).unwrap(); + self.font_cache_thread.exit(); self.compositor_proxy.send(ToCompositorMsg::ShutdownComplete); } @@ -749,7 +749,7 @@ impl Constellation { pipeline_id: PipelineId, parent_info: Option<(PipelineId, SubpageId)>) { if opts::get().hard_fail { - // It's quite difficult to make Servo exit cleanly if some tasks have failed. + // It's quite difficult to make Servo exit cleanly if some threads have failed. // Hard fail exists for test runners so we crash and that's good enough. let mut stderr = io::stderr(); stderr.write_all("Pipeline failed in hard-fail mode. Crashing!\n".as_bytes()).unwrap(); @@ -825,7 +825,7 @@ impl Constellation { parent_pipeline.script_chan.send(msg).unwrap(); } - // The script task associated with pipeline_id has loaded a URL in an iframe via script. This + // The script thread associated with pipeline_id has loaded a URL in an iframe via script. This // will result in a new pipeline being spawned and a frame tree being added to // containing_page_pipeline_id's frame tree's children. This message is never the result of a // page navigation. @@ -842,7 +842,7 @@ impl Constellation { }; // Compare the pipeline's url to the new url. If the origin is the same, - // then reuse the script task in creating the new pipeline + // then reuse the script thread in creating the new pipeline let script_chan = { let source_pipeline = self.pipeline(load_info.containing_pipeline_id); @@ -853,7 +853,7 @@ impl Constellation { load_info.sandbox == IFrameSandboxState::IFrameUnsandboxed; // FIXME(tkuehn): Need to follow the standardized spec for checking same-origin - // Reuse the script task if the URL is same-origin + // Reuse the script thread if the URL is same-origin if same_script { debug!("Constellation: loading same-origin iframe, \ parent url {:?}, iframe url {:?}", source_url, new_url); @@ -910,13 +910,13 @@ impl Constellation { fn load_url(&mut self, source_id: PipelineId, load_data: LoadData) -> Option { // If this load targets an iframe, its framing element may exist - // in a separate script task than the framed document that initiated + // in a separate script thread than the framed document that initiated // the new load. The framing element must be notified about the // requested change so it can update its internal state. match self.pipeline(source_id).parent_info { Some((parent_pipeline_id, subpage_id)) => { self.handle_load_start_msg(&source_id); - // Message the constellation to find the script task for this iframe + // Message the constellation to find the script thread for this iframe // and issue an iframe load through there. let parent_pipeline = self.pipeline(parent_pipeline_id); let script_channel = &parent_pipeline.script_chan; @@ -944,7 +944,7 @@ impl Constellation { self.new_pipeline(new_pipeline_id, None, window_size, None, load_data); self.push_pending_frame(new_pipeline_id, Some(source_id)); - // Send message to ScriptTask that will suspend all timers + // Send message to ScriptThread that will suspend all timers let old_pipeline = self.pipelines.get(&source_id).unwrap(); old_pipeline.freeze(); Some(new_pipeline_id) @@ -1111,7 +1111,7 @@ impl Constellation { assert!(prefs::get_pref("dom.mozbrowser.enabled").as_boolean().unwrap_or(false)); // Find the script channel for the given parent pipeline, - // and pass the event to that script task. + // and pass the event to that script thread. let pipeline = self.pipeline(containing_pipeline_id); pipeline.trigger_mozbrowser_event(subpage_id, event); } @@ -1171,25 +1171,25 @@ impl Constellation { } } - fn handle_create_canvas_paint_task_msg( + fn handle_create_canvas_paint_thread_msg( &mut self, size: &Size2D, response_sender: IpcSender<(IpcSender, usize)>) { - let id = self.canvas_paint_tasks.len(); - let (out_of_process_sender, in_process_sender) = CanvasPaintTask::start(*size); - self.canvas_paint_tasks.push(in_process_sender); + let id = self.canvas_paint_threads.len(); + let (out_of_process_sender, in_process_sender) = CanvasPaintThread::start(*size); + self.canvas_paint_threads.push(in_process_sender); response_sender.send((out_of_process_sender, id)).unwrap() } - fn handle_create_webgl_paint_task_msg( + fn handle_create_webgl_paint_thread_msg( &mut self, size: &Size2D, attributes: GLContextAttributes, response_sender: IpcSender, usize), String>>) { - let response = match WebGLPaintTask::start(*size, attributes) { + let response = match WebGLPaintThread::start(*size, attributes) { Ok((out_of_process_sender, in_process_sender)) => { - let id = self.webgl_paint_tasks.len(); - self.webgl_paint_tasks.push(in_process_sender); + let id = self.webgl_paint_threads.len(); + self.webgl_paint_threads.push(in_process_sender); Ok((out_of_process_sender, id)) }, Err(msg) => Err(msg.to_owned()), @@ -1200,7 +1200,7 @@ impl Constellation { fn handle_webdriver_msg(&mut self, msg: WebDriverCommandMsg) { // Find the script channel for the given parent pipeline, - // and pass the event to that script task. + // and pass the event to that script thread. match msg { WebDriverCommandMsg::LoadUrl(pipeline_id, load_data, reply) => { self.load_url_for_webdriver(pipeline_id, load_data, reply); @@ -1404,7 +1404,7 @@ impl Constellation { } // Step through the current frame tree, checking that the script - // task is idle, and that the current epoch of the layout task + // thread is idle, and that the current epoch of the layout thread // matches what the compositor has painted. If all these conditions // are met, then the output image should not change and a reftest // screenshot can safely be written. @@ -1441,7 +1441,7 @@ impl Constellation { if let Some(size) = pipeline.size { // If the rectangle for this pipeline is zero sized, it will // never be painted. In this case, don't query the layout - // task as it won't contribute to the final output image. + // thread as it won't contribute to the final output image. if size == Size2D::zero() { continue; } @@ -1450,15 +1450,15 @@ impl Constellation { let compositor_epoch = pipeline_states.get(&frame.current); match compositor_epoch { Some(compositor_epoch) => { - // Synchronously query the layout task to see if the current + // Synchronously query the layout thread to see if the current // epoch matches what the compositor has drawn. If they match // (and script is idle) then this pipeline won't change again // and can be considered stable. let (sender, receiver) = ipc::channel().unwrap(); let LayoutControlChan(ref layout_chan) = pipeline.layout_chan; layout_chan.send(LayoutControlMsg::GetCurrentEpoch(sender)).unwrap(); - let layout_task_epoch = receiver.recv().unwrap(); - if layout_task_epoch != *compositor_epoch { + let layout_thread_epoch = receiver.recv().unwrap(); + if layout_thread_epoch != *compositor_epoch { return ReadyToSave::EpochMismatch; } } @@ -1471,7 +1471,7 @@ impl Constellation { } } - // All script tasks are idle and layout epochs match compositor, so output image! + // All script threads are idle and layout epochs match compositor, so output image! ReadyToSave::Ready } diff --git a/components/compositing/headless.rs b/components/compositing/headless.rs index 85af3b7f622..7289f805133 100644 --- a/components/compositing/headless.rs +++ b/components/compositing/headless.rs @@ -3,8 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use CompositorMsg as ConstellationMsg; -use compositor_task::{CompositorEventListener, CompositorReceiver}; -use compositor_task::{InitialCompositorState, Msg}; +use compositor_thread::{CompositorEventListener, CompositorReceiver}; +use compositor_thread::{InitialCompositorState, Msg}; use euclid::scale_factor::ScaleFactor; use euclid::{Point2D, Size2D}; use msg::constellation_msg::AnimationState; @@ -70,7 +70,7 @@ impl CompositorEventListener for NullCompositor { debug!("constellation completed shutdown"); // Drain compositor port, sometimes messages contain channels that are blocking - // another task from finishing (i.e. SetIds) + // another thread from finishing (i.e. SetIds) while self.port.try_recv_compositor_msg().is_some() {} self.time_profiler_chan.send(time::ProfilerMsg::Exit); @@ -123,7 +123,7 @@ impl CompositorEventListener for NullCompositor { Msg::SetCursor(..) | Msg::ViewportConstrained(..) => {} Msg::CreatePng(..) | - Msg::PaintTaskExited(..) | + Msg::PaintThreadExited(..) | Msg::MoveTo(..) | Msg::ResizeTo(..) | Msg::IsReadyToSaveImageReply(..) => {} diff --git a/components/compositing/lib.rs b/components/compositing/lib.rs index 1ea72338c34..4264236a8c0 100644 --- a/components/compositing/lib.rs +++ b/components/compositing/lib.rs @@ -50,7 +50,7 @@ extern crate url; #[macro_use] extern crate util; -pub use compositor_task::{CompositorEventListener, CompositorProxy, CompositorTask}; +pub use compositor_thread::{CompositorEventListener, CompositorProxy, CompositorThread}; pub use constellation::Constellation; use euclid::size::{Size2D}; use ipc_channel::ipc::{IpcSender}; @@ -63,7 +63,7 @@ use url::Url; mod compositor; mod compositor_layer; -pub mod compositor_task; +pub mod compositor_thread; pub mod constellation; mod headless; pub mod pipeline; diff --git a/components/compositing/pipeline.rs b/components/compositing/pipeline.rs index 47aab2126e2..3c49bbf41db 100644 --- a/components/compositing/pipeline.rs +++ b/components/compositing/pipeline.rs @@ -3,29 +3,29 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use CompositorProxy; -use compositor_task; -use compositor_task::Msg as CompositorMsg; +use compositor_thread; +use compositor_thread::Msg as CompositorMsg; use devtools_traits::{DevtoolsControlMsg, ScriptToDevtoolsControlMsg}; use euclid::scale_factor::ScaleFactor; use euclid::size::TypedSize2D; -use gfx::font_cache_task::FontCacheTask; -use gfx::paint_task::{ChromeToPaintMsg, LayoutToPaintMsg, PaintTask}; +use gfx::font_cache_thread::FontCacheThread; +use gfx::paint_thread::{ChromeToPaintMsg, LayoutToPaintMsg, PaintThread}; use gfx_traits::PaintMsg; use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; use ipc_channel::router::ROUTER; use layers::geometry::DevicePixel; -use layout_traits::{LayoutControlChan, LayoutTaskFactory}; +use layout_traits::{LayoutControlChan, LayoutThreadFactory}; use msg::constellation_msg::{ConstellationChan, Failure, FrameId, PipelineId, SubpageId}; use msg::constellation_msg::{LoadData, MozBrowserEvent, WindowSizeData}; use msg::constellation_msg::{PipelineNamespaceId}; -use net_traits::ResourceTask; -use net_traits::image_cache_task::ImageCacheTask; -use net_traits::storage_task::StorageTask; +use net_traits::ResourceThread; +use net_traits::image_cache_thread::ImageCacheThread; +use net_traits::storage_thread::StorageThread; use profile_traits::mem as profile_mem; use profile_traits::time; use script_traits::{ConstellationControlMsg, InitialScriptState}; use script_traits::{LayoutControlMsg, LayoutMsg, NewLayoutInfo, ScriptMsg}; -use script_traits::{ScriptToCompositorMsg, ScriptTaskFactory, TimerEventRequest}; +use script_traits::{ScriptToCompositorMsg, ScriptThreadFactory, TimerEventRequest}; use std::mem; use std::sync::mpsc::{Receiver, Sender, channel}; use std::thread; @@ -36,7 +36,7 @@ use util::ipc::OptionalIpcSender; use util::opts::{self, Opts}; use util::prefs; -/// A uniquely-identifiable pipeline of script task, layout task, and paint task. +/// A uniquely-identifiable pipeline of script thread, layout thread, and paint thread. pub struct Pipeline { pub id: PipelineId, pub parent_info: Option<(PipelineId, SubpageId)>, @@ -80,9 +80,9 @@ pub struct InitialPipelineState { pub parent_info: Option<(PipelineId, SubpageId)>, /// A channel to the associated constellation. pub constellation_chan: ConstellationChan, - /// A channel for the layout task to send messages to the constellation. + /// A channel for the layout thread to send messages to the constellation. pub layout_to_constellation_chan: ConstellationChan, - /// A channel to the associated paint task. + /// A channel to the associated paint thread. pub painter_chan: ConstellationChan, /// A channel to schedule timer events. pub scheduler_chan: IpcSender, @@ -90,14 +90,14 @@ pub struct InitialPipelineState { pub compositor_proxy: Box, /// A channel to the developer tools, if applicable. pub devtools_chan: Option>, - /// A channel to the image cache task. - pub image_cache_task: ImageCacheTask, - /// A channel to the font cache task. - pub font_cache_task: FontCacheTask, - /// A channel to the resource task. - pub resource_task: ResourceTask, - /// A channel to the storage task. - pub storage_task: StorageTask, + /// A channel to the image cache thread. + pub image_cache_thread: ImageCacheThread, + /// A channel to the font cache thread. + pub font_cache_thread: FontCacheThread, + /// A channel to the resource thread. + pub resource_thread: ResourceThread, + /// A channel to the storage thread. + pub storage_thread: StorageThread, /// A channel to the time profiler thread. pub time_profiler_chan: time::ProfilerChan, /// A channel to the memory profiler thread. @@ -116,11 +116,11 @@ pub struct InitialPipelineState { } impl Pipeline { - /// Starts a paint task, layout task, and possibly a script task. + /// Starts a paint thread, layout thread, and possibly a script thread. /// Returns the channels wrapped in a struct. pub fn create(state: InitialPipelineState) -> (Pipeline, UnprivilegedPipelineContent, PrivilegedPipelineContent) - where LTF: LayoutTaskFactory, STF: ScriptTaskFactory { + where LTF: LayoutThreadFactory, STF: ScriptThreadFactory { let (layout_to_paint_chan, layout_to_paint_port) = util::ipc::optional_ipc_channel(); let (chrome_to_paint_chan, chrome_to_paint_port) = channel(); let (paint_shutdown_chan, paint_shutdown_port) = ipc::channel().unwrap(); @@ -202,10 +202,10 @@ impl Pipeline { constellation_chan: state.constellation_chan, scheduler_chan: state.scheduler_chan, devtools_chan: script_to_devtools_chan, - image_cache_task: state.image_cache_task, - font_cache_task: state.font_cache_task.clone(), - resource_task: state.resource_task, - storage_task: state.storage_task, + image_cache_thread: state.image_cache_thread, + font_cache_thread: state.font_cache_thread.clone(), + resource_thread: state.resource_thread, + storage_thread: state.storage_thread, time_profiler_chan: state.time_profiler_chan.clone(), mem_profiler_chan: state.mem_profiler_chan.clone(), window_size: window_size, @@ -231,7 +231,7 @@ impl Pipeline { id: state.id, painter_chan: state.painter_chan, compositor_proxy: state.compositor_proxy, - font_cache_task: state.font_cache_task, + font_cache_thread: state.font_cache_thread, time_profiler_chan: state.time_profiler_chan, mem_profiler_chan: state.mem_profiler_chan, load_data: state.load_data, @@ -286,13 +286,13 @@ impl Pipeline { pub fn exit(&self) { debug!("pipeline {:?} exiting", self.id); - // Script task handles shutting down layout, and layout handles shutting down the painter. - // For now, if the script task has failed, we give up on clean shutdown. + // Script thread handles shutting down layout, and layout handles shutting down the painter. + // For now, if the script thread has failed, we give up on clean shutdown. if self.script_chan .send(ConstellationControlMsg::ExitPipeline(self.id)) .is_ok() { - // Wait until all slave tasks have terminated and run destructors - // NOTE: We don't wait for script task as we don't always own it + // Wait until all slave threads have terminated and run destructors + // NOTE: We don't wait for script thread as we don't always own it let _ = self.paint_shutdown_port.recv(); let _ = self.layout_shutdown_port.recv(); } @@ -355,10 +355,10 @@ pub struct UnprivilegedPipelineContent { scheduler_chan: IpcSender, devtools_chan: Option>, script_to_compositor_chan: IpcSender, - image_cache_task: ImageCacheTask, - font_cache_task: FontCacheTask, - resource_task: ResourceTask, - storage_task: StorageTask, + image_cache_thread: ImageCacheThread, + font_cache_thread: FontCacheThread, + resource_thread: ResourceThread, + storage_thread: StorageThread, time_profiler_chan: time::ProfilerChan, mem_profiler_chan: profile_mem::ProfilerChan, window_size: Option, @@ -380,10 +380,10 @@ pub struct UnprivilegedPipelineContent { impl UnprivilegedPipelineContent { pub fn start_all(mut self, wait_for_completion: bool) - where LTF: LayoutTaskFactory, STF: ScriptTaskFactory { - let layout_pair = ScriptTaskFactory::create_layout_channel(None::<&mut STF>); + where LTF: LayoutThreadFactory, STF: ScriptThreadFactory { + let layout_pair = ScriptThreadFactory::create_layout_channel(None::<&mut STF>); - ScriptTaskFactory::create(None::<&mut STF>, InitialScriptState { + ScriptThreadFactory::create(None::<&mut STF>, InitialScriptState { id: self.id, parent_info: self.parent_info, compositor: self.script_to_compositor_chan, @@ -393,9 +393,9 @@ impl UnprivilegedPipelineContent { layout_to_constellation_chan: self.layout_to_constellation_chan.clone(), scheduler_chan: self.scheduler_chan.clone(), failure_info: self.failure.clone(), - resource_task: self.resource_task, - storage_task: self.storage_task.clone(), - image_cache_task: self.image_cache_task.clone(), + resource_thread: self.resource_thread, + storage_thread: self.storage_thread.clone(), + image_cache_thread: self.image_cache_thread.clone(), time_profiler_chan: self.time_profiler_chan.clone(), mem_profiler_chan: self.mem_profiler_chan.clone(), devtools_chan: self.devtools_chan, @@ -404,7 +404,7 @@ impl UnprivilegedPipelineContent { content_process_shutdown_chan: self.script_content_process_shutdown_chan.clone(), }, &layout_pair, self.load_data.clone()); - LayoutTaskFactory::create(None::<&mut LTF>, + LayoutThreadFactory::create(None::<&mut LTF>, self.id, self.load_data.url.clone(), self.parent_info.is_some(), @@ -414,8 +414,8 @@ impl UnprivilegedPipelineContent { self.failure, self.script_chan.clone(), self.layout_to_paint_chan.clone(), - self.image_cache_task, - self.font_cache_task, + self.image_cache_thread, + self.font_cache_thread, self.time_profiler_chan, self.mem_profiler_chan, self.layout_shutdown_chan, @@ -437,7 +437,7 @@ pub struct PrivilegedPipelineContent { painter_chan: ConstellationChan, compositor_proxy: Box, script_to_compositor_port: IpcReceiver, - font_cache_task: FontCacheTask, + font_cache_thread: FontCacheThread, time_profiler_chan: time::ProfilerChan, mem_profiler_chan: profile_mem::ProfilerChan, load_data: LoadData, @@ -450,14 +450,14 @@ pub struct PrivilegedPipelineContent { impl PrivilegedPipelineContent { pub fn start_all(self) { - PaintTask::create(self.id, + PaintThread::create(self.id, self.load_data.url, self.chrome_to_paint_chan, self.layout_to_paint_port, self.chrome_to_paint_port, self.compositor_proxy.clone_compositor_proxy(), self.painter_chan, - self.font_cache_task, + self.font_cache_thread, self.failure, self.time_profiler_chan, self.mem_profiler_chan, @@ -467,21 +467,21 @@ impl PrivilegedPipelineContent { self.compositor_proxy.clone_compositor_proxy(); let script_to_compositor_port = self.script_to_compositor_port; thread::spawn(move || { - compositor_task::run_script_listener_thread( + compositor_thread::run_script_listener_thread( compositor_proxy_for_script_listener_thread, script_to_compositor_port) }); } - pub fn start_paint_task(self) { - PaintTask::create(self.id, + pub fn start_paint_thread(self) { + PaintThread::create(self.id, self.load_data.url, self.chrome_to_paint_chan, self.layout_to_paint_port, self.chrome_to_paint_port, self.compositor_proxy, self.painter_chan, - self.font_cache_task, + self.font_cache_thread, self.failure, self.time_profiler_chan, self.mem_profiler_chan, diff --git a/components/compositing/scrolling.rs b/components/compositing/scrolling.rs index 2b1bee543fb..b0551b6722c 100644 --- a/components/compositing/scrolling.rs +++ b/components/compositing/scrolling.rs @@ -2,9 +2,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -//! A timer thread that gives the painting task a little time to catch up when the user scrolls. +//! A timer thread that gives the painting thread a little time to catch up when the user scrolls. -use compositor_task::{CompositorProxy, Msg}; +use compositor_thread::{CompositorProxy, Msg}; use std::sync::mpsc::{Receiver, Sender, channel}; use std::thread::{self, Builder}; use time; diff --git a/components/compositing/surface_map.rs b/components/compositing/surface_map.rs index e91bbf5aaf5..d5f0cfba2f7 100644 --- a/components/compositing/surface_map.rs +++ b/components/compositing/surface_map.rs @@ -9,7 +9,7 @@ use std::collections::hash_map::Entry::{Occupied, Vacant}; use std::hash::{Hash, Hasher}; /// This is a struct used to store surfaces when they are not in use. -/// The paint task can quickly query for a particular size of surface when it +/// The paint thread can quickly query for a particular size of surface when it /// needs it. pub struct SurfaceMap { /// A HashMap that stores the Buffers. diff --git a/components/compositing/timer_scheduler.rs b/components/compositing/timer_scheduler.rs index 528dc17821d..3ae43f613bb 100644 --- a/components/compositing/timer_scheduler.rs +++ b/components/compositing/timer_scheduler.rs @@ -16,7 +16,7 @@ use std::sync::atomic::{self, AtomicBool}; use std::sync::mpsc::{channel, Receiver, Select}; use std::thread::{self, spawn, Thread}; use std::time::Duration; -use util::task::spawn_named; +use util::thread::spawn_named; /// A quick hack to work around the removal of [`std::old_io::timer::Timer`]( /// http://doc.rust-lang.org/1.0.0-beta/std/old_io/timer/struct.Timer.html ) @@ -129,8 +129,8 @@ impl TimerScheduler { } fn run_event_loop(&self) { - while let Some(task) = self.receive_next_task() { - match task { + while let Some(thread) = self.receive_next_task() { + match thread { Task::HandleRequest(request) => self.handle_request(request), Task::DispatchDueEvents => self.dispatch_due_events(), } diff --git a/components/compositing/windowing.rs b/components/compositing/windowing.rs index 2a9dcb9bcb0..0dc4e1e46c8 100644 --- a/components/compositing/windowing.rs +++ b/components/compositing/windowing.rs @@ -4,7 +4,7 @@ //! Abstract windowing methods. The concrete implementations of these can be found in `platform/`. -use compositor_task::{CompositorProxy, CompositorReceiver}; +use compositor_thread::{CompositorProxy, CompositorReceiver}; use euclid::point::TypedPoint2D; use euclid::scale_factor::ScaleFactor; use euclid::size::TypedSize2D; @@ -41,7 +41,7 @@ pub enum WindowEvent { /// /// FIXME(pcwalton): This is kind of ugly and may not work well with multiprocess Servo. /// It's possible that this should be something like - /// `CompositorMessageWindowEvent(compositor_task::Msg)` instead. + /// `CompositorMessageWindowEvent(compositor_thread::Msg)` instead. Idle, /// Sent when part of the window is marked dirty and needs to be redrawn. Before sending this /// message, the window must make the same GL context as in `PrepareRenderingEvent` current. diff --git a/components/devtools/actors/timeline.rs b/components/devtools/actors/timeline.rs index 56ac06c40b2..f639d24ead9 100644 --- a/components/devtools/actors/timeline.rs +++ b/components/devtools/actors/timeline.rs @@ -18,7 +18,7 @@ use std::sync::mpsc::channel; use std::sync::{Arc, Mutex}; use std::thread; use std::time::Duration; -use util::task; +use util::thread::spawn_named; pub struct TimelineActor { name: String, @@ -147,7 +147,7 @@ impl TimelineActor { return; } - task::spawn_named("PullTimelineMarkers".to_owned(), move || { + spawn_named("PullTimelineMarkers".to_owned(), move || { loop { if !*is_recording.lock().unwrap() { break; diff --git a/components/devtools/lib.rs b/components/devtools/lib.rs index 85d360e701c..5fd7191b586 100644 --- a/components/devtools/lib.rs +++ b/components/devtools/lib.rs @@ -58,7 +58,7 @@ use std::net::{Shutdown, TcpListener, TcpStream}; use std::sync::mpsc::{Receiver, Sender, channel}; use std::sync::{Arc, Mutex}; use time::precise_time_ns; -use util::task::spawn_named; +use util::thread::spawn_named; mod actor; /// Corresponds to http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/ @@ -506,7 +506,7 @@ fn run_server(sender: Sender, let sender_clone = sender.clone(); spawn_named("DevtoolsClientAcceptor".to_owned(), move || { - // accept connections and process them, spawning a new task for each one + // accept connections and process them, spawning a new thread for each one for stream in listener.incoming() { // connection succeeded sender_clone.send(DevtoolsControlMsg::FromChrome( diff --git a/components/devtools_traits/lib.rs b/components/devtools_traits/lib.rs index b914e8dfda2..59cb1d27cba 100644 --- a/components/devtools_traits/lib.rs +++ b/components/devtools_traits/lib.rs @@ -48,9 +48,9 @@ pub struct DevtoolsPageInfo { /// Messages to instruct the devtools server to update its known actors/state /// according to changes in the browser. pub enum DevtoolsControlMsg { - /// Messages from tasks in the chrome process (resource/constellation/devtools) + /// Messages from threads in the chrome process (resource/constellation/devtools) FromChrome(ChromeToDevtoolsControlMsg), - /// Messages from script tasks + /// Messages from script threads FromScript(ScriptToDevtoolsControlMsg), } @@ -75,7 +75,7 @@ pub enum ScriptToDevtoolsControlMsg { DevtoolsPageInfo), /// A particular page has invoked the console API. ConsoleAPI(PipelineId, ConsoleMessage, Option), - /// An animation frame with the given timestamp was processed in a script task. + /// An animation frame with the given timestamp was processed in a script thread. /// The actor with the provided name should be notified. FramerateTick(String, f64), } @@ -149,7 +149,7 @@ pub struct ComputedNodeLayout { pub height: f32, } -/// Messages to process in a particular script task, as instructed by a devtools client. +/// Messages to process in a particular script thread, as instructed by a devtools client. #[derive(Deserialize, Serialize)] pub enum DevtoolScriptControlMsg { /// Evaluate a JS snippet in the context of the global for the given pipeline. diff --git a/components/gfx/display_list/mod.rs b/components/gfx/display_list/mod.rs index 6223a8e5f7f..592ac61cd2e 100644 --- a/components/gfx/display_list/mod.rs +++ b/components/gfx/display_list/mod.rs @@ -25,7 +25,7 @@ use gfx_traits::{color, LayerId, LayerKind, ScrollPolicy}; use msg::constellation_msg::PipelineId; use net_traits::image::base::Image; use paint_context::PaintContext; -use paint_task::{PaintLayerContents, PaintLayer}; +use paint_thread::{PaintLayerContents, PaintLayer}; use self::DisplayItem::*; use self::DisplayItemIterator::*; use smallvec::SmallVec; @@ -1140,7 +1140,7 @@ impl ClippingRegion { } -/// Metadata attached to each display item. This is useful for performing auxiliary tasks with +/// Metadata attached to each display item. This is useful for performing auxiliary threads with /// the display list involving hit testing: finding the originating DOM node and determining the /// cursor to use when the element is hovered over. #[derive(Clone, Copy, HeapSizeOf, Deserialize, Serialize)] diff --git a/components/gfx/font_cache_task.rs b/components/gfx/font_cache_thread.rs similarity index 95% rename from components/gfx/font_cache_task.rs rename to components/gfx/font_cache_thread.rs index ab3d67c6538..96e6bd98c58 100644 --- a/components/gfx/font_cache_task.rs +++ b/components/gfx/font_cache_thread.rs @@ -6,7 +6,7 @@ use font_template::{FontTemplate, FontTemplateDescriptor}; use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; use ipc_channel::router::ROUTER; use mime::{TopLevel, SubLevel}; -use net_traits::{AsyncResponseTarget, LoadContext, PendingAsyncLoad, ResourceTask, ResponseAction}; +use net_traits::{AsyncResponseTarget, LoadContext, PendingAsyncLoad, ResourceThread, ResponseAction}; use platform::font_context::FontContextHandle; use platform::font_list::for_each_available_family; use platform::font_list::for_each_variation; @@ -24,7 +24,7 @@ use style::properties::longhands::font_family::computed_value::FontFamily; use url::Url; use util::prefs; use util::str::LowercaseString; -use util::task::spawn_named; +use util::thread::spawn_named; /// A list of font templates that make up a given font family. struct FontTemplates { @@ -79,7 +79,7 @@ impl FontTemplates { } } -/// Commands that the FontContext sends to the font cache task. +/// Commands that the FontContext sends to the font cache thread. #[derive(Deserialize, Serialize, Debug)] pub enum Command { GetFontTemplate(FontFamily, FontTemplateDescriptor, IpcSender), @@ -89,13 +89,13 @@ pub enum Command { Exit(IpcSender<()>), } -/// Reply messages sent from the font cache task to the FontContext caller. +/// Reply messages sent from the font cache thread to the FontContext caller. #[derive(Deserialize, Serialize, Debug)] pub enum Reply { GetFontTemplateReply(Option>), } -/// The font cache task itself. It maintains a list of reference counted +/// The font cache thread itself. It maintains a list of reference counted /// font templates that are currently in use. struct FontCache { port: IpcReceiver, @@ -104,7 +104,7 @@ struct FontCache { local_families: HashMap, web_families: HashMap, font_context: FontContextHandle, - resource_task: ResourceTask, + resource_thread: ResourceThread, } fn populate_generic_fonts() -> HashMap { @@ -159,7 +159,7 @@ impl FontCache { Source::Url(ref url_source) => { let url = &url_source.url; let load = PendingAsyncLoad::new(LoadContext::Font, - self.resource_task.clone(), + self.resource_thread.clone(), url.clone(), None); let (data_sender, data_receiver) = ipc::channel().unwrap(); @@ -311,19 +311,19 @@ impl FontCache { } } -/// The public interface to the font cache task, used exclusively by -/// the per-thread/task FontContext structures. +/// The public interface to the font cache thread, used exclusively by +/// the per-thread/thread FontContext structures. #[derive(Clone, Deserialize, Serialize, Debug)] -pub struct FontCacheTask { +pub struct FontCacheThread { chan: IpcSender, } -impl FontCacheTask { - pub fn new(resource_task: ResourceTask) -> FontCacheTask { +impl FontCacheThread { + pub fn new(resource_thread: ResourceThread) -> FontCacheThread { let (chan, port) = ipc::channel().unwrap(); let channel_to_self = chan.clone(); - spawn_named("FontCacheTask".to_owned(), move || { + spawn_named("FontCacheThread".to_owned(), move || { // TODO: Allow users to specify these. let generic_fonts = populate_generic_fonts(); @@ -334,14 +334,14 @@ impl FontCacheTask { local_families: HashMap::new(), web_families: HashMap::new(), font_context: FontContextHandle::new(), - resource_task: resource_task, + resource_thread: resource_thread, }; cache.refresh_local_families(); cache.run(); }); - FontCacheTask { + FontCacheThread { chan: chan, } } diff --git a/components/gfx/font_context.rs b/components/gfx/font_context.rs index 0113326a360..7f18c81cf67 100644 --- a/components/gfx/font_context.rs +++ b/components/gfx/font_context.rs @@ -11,7 +11,7 @@ use fnv::FnvHasher; use font::FontHandleMethods; use font::SpecifiedFontStyle; use font::{Font, FontGroup}; -use font_cache_task::FontCacheTask; +use font_cache_thread::FontCacheThread; use font_template::FontTemplateDescriptor; use platform::font::FontHandle; use platform::font_context::FontContextHandle; @@ -55,7 +55,7 @@ struct FallbackFontCacheEntry { font: Rc>, } -/// A cached azure font (per paint task) that +/// A cached azure font (per paint thread) that /// can be shared by multiple text runs. #[derive(Debug)] struct PaintFontCacheEntry { @@ -68,14 +68,14 @@ struct PaintFontCacheEntry { /// this one. static FONT_CACHE_EPOCH: AtomicUsize = ATOMIC_USIZE_INIT; -/// The FontContext represents the per-thread/task state necessary for +/// The FontContext represents the per-thread/thread state necessary for /// working with fonts. It is the public API used by the layout and -/// paint code. It talks directly to the font cache task where +/// paint code. It talks directly to the font cache thread where /// required. #[derive(Debug)] pub struct FontContext { platform_handle: FontContextHandle, - font_cache_task: FontCacheTask, + font_cache_thread: FontCacheThread, /// TODO: See bug https://github.com/servo/servo/issues/3300. layout_font_cache: Vec, @@ -92,11 +92,11 @@ pub struct FontContext { } impl FontContext { - pub fn new(font_cache_task: FontCacheTask) -> FontContext { + pub fn new(font_cache_thread: FontCacheThread) -> FontContext { let handle = FontContextHandle::new(); FontContext { platform_handle: handle, - font_cache_task: font_cache_task, + font_cache_thread: font_cache_thread, layout_font_cache: vec!(), fallback_font_cache: vec!(), paint_font_cache: vec!(), @@ -202,7 +202,7 @@ impl FontContext { } if !cache_hit { - let font_template = self.font_cache_task.find_font_template(family.clone(), + let font_template = self.font_cache_thread.find_font_template(family.clone(), desc.clone()); match font_template { Some(font_template) => { @@ -251,7 +251,7 @@ impl FontContext { } if !cache_hit { - let font_template = self.font_cache_task.last_resort_font_template(desc.clone()); + let font_template = self.font_cache_thread.last_resort_font_template(desc.clone()); let layout_font = self.create_layout_font(font_template, desc.clone(), style.font_size, @@ -296,9 +296,9 @@ impl FontContext { paint_font } - /// Returns a reference to the font cache task. - pub fn font_cache_task(&self) -> FontCacheTask { - self.font_cache_task.clone() + /// Returns a reference to the font cache thread. + pub fn font_cache_thread(&self) -> FontCacheThread { + self.font_cache_thread.clone() } } diff --git a/components/gfx/lib.rs b/components/gfx/lib.rs index 3b3d8b6ce2f..733178559d8 100644 --- a/components/gfx/lib.rs +++ b/components/gfx/lib.rs @@ -91,11 +91,11 @@ pub mod display_list; // Fonts pub mod font; -pub mod font_cache_task; +pub mod font_cache_thread; pub mod font_context; pub mod font_template; -pub mod paint_task; +pub mod paint_thread; // Platform-specific implementations. #[path = "platform/mod.rs"] diff --git a/components/gfx/paint_task.rs b/components/gfx/paint_thread.rs similarity index 94% rename from components/gfx/paint_task.rs rename to components/gfx/paint_thread.rs index 9c9edcbe40b..d1ca334fcd4 100644 --- a/components/gfx/paint_task.rs +++ b/components/gfx/paint_thread.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -//! The task that handles all painting. +//! The thread that handles all painting. use app_units::Au; use azure::AzFloat; @@ -13,7 +13,7 @@ use euclid::Matrix4; use euclid::point::Point2D; use euclid::rect::Rect; use euclid::size::Size2D; -use font_cache_task::FontCacheTask; +use font_cache_thread::FontCacheThread; use font_context::FontContext; use gfx_traits::{color, LayerId, LayerKind, LayerProperties, PaintListener, PaintMsg as ConstellationMsg, ScrollPolicy}; use ipc_channel::ipc::IpcSender; @@ -34,8 +34,8 @@ use std::sync::mpsc::{Receiver, Select, Sender, channel}; use url::Url; use util::geometry::{ExpandToPixelBoundaries}; use util::opts; -use util::task; -use util::task_state; +use util::thread; +use util::thread_state; #[derive(Clone, Deserialize, Serialize, HeapSizeOf)] pub enum PaintLayerContents { @@ -43,7 +43,7 @@ pub enum PaintLayerContents { DisplayList(Arc), } -/// Information about a hardware graphics layer that layout sends to the painting task. +/// Information about a hardware graphics layer that layout sends to the painting thread. #[derive(Clone, Deserialize, Serialize, HeapSizeOf)] pub struct PaintLayer { /// A per-pipeline ID describing this layer that should be stable across reflows. @@ -205,7 +205,7 @@ pub enum ChromeToPaintMsg { Exit, } -pub struct PaintTask { +pub struct PaintThread { id: PipelineId, _url: Url, layout_to_paint_port: Receiver, @@ -221,7 +221,7 @@ pub struct PaintTask { /// Permission to send paint messages to the compositor paint_permission: bool, - /// The current epoch counter is passed by the layout task + /// The current epoch counter is passed by the layout thread current_epoch: Option, /// Communication handles to each of the worker threads. @@ -232,14 +232,14 @@ pub struct PaintTask { } // If we implement this as a function, we get borrowck errors from borrowing -// the whole PaintTask struct. +// the whole PaintThread struct. macro_rules! native_display( - ($task:expr) => ( - $task.native_display.as_ref().expect("Need a graphics context to do painting") + ($thread:expr) => ( + $thread.native_display.as_ref().expect("Need a graphics context to do painting") ) ); -impl PaintTask where C: PaintListener + Send + 'static { +impl PaintThread where C: PaintListener + Send + 'static { pub fn create(id: PipelineId, url: Url, chrome_to_paint_chan: Sender, @@ -247,26 +247,26 @@ impl PaintTask where C: PaintListener + Send + 'static { chrome_to_paint_port: Receiver, compositor: C, constellation_chan: ConstellationChan, - font_cache_task: FontCacheTask, + font_cache_thread: FontCacheThread, failure_msg: Failure, time_profiler_chan: time::ProfilerChan, mem_profiler_chan: mem::ProfilerChan, shutdown_chan: IpcSender<()>) { let ConstellationChan(c) = constellation_chan.clone(); - task::spawn_named_with_send_on_failure(format!("PaintTask {:?}", id), - task_state::PAINT, + thread::spawn_named_with_send_on_failure(format!("PaintThread {:?}", id), + thread_state::PAINT, move || { { - // Ensures that the paint task and graphics context are destroyed before the + // Ensures that the paint thread and graphics context are destroyed before the // shutdown message. let mut compositor = compositor; let native_display = compositor.native_display().map( |display| display); let worker_threads = WorkerThreadProxy::spawn(native_display.clone(), - font_cache_task, + font_cache_thread, time_profiler_chan.clone()); - let mut paint_task = PaintTask { + let mut paint_thread = PaintThread { id: id, _url: url, layout_to_paint_port: layout_to_paint_port, @@ -282,22 +282,22 @@ impl PaintTask where C: PaintListener + Send + 'static { let reporter_name = format!("paint-reporter-{}", id); mem_profiler_chan.run_with_memory_reporting(|| { - paint_task.start(); + paint_thread.start(); }, reporter_name, chrome_to_paint_chan, ChromeToPaintMsg::CollectReports); // Tell all the worker threads to shut down. - for worker_thread in &mut paint_task.worker_threads { + for worker_thread in &mut paint_thread.worker_threads { worker_thread.exit() } } - debug!("paint_task: shutdown_chan send"); + debug!("paint_thread: shutdown_chan send"); shutdown_chan.send(()).unwrap(); }, ConstellationMsg::Failure(failure_msg), c); } fn start(&mut self) { - debug!("PaintTask: beginning painting loop"); + debug!("PaintThread: beginning painting loop"); loop { let message = { @@ -340,14 +340,14 @@ impl PaintTask where C: PaintListener + Send + 'static { if self.current_epoch == Some(epoch) { self.paint(&mut replies, buffer_requests, scale, layer_id, layer_kind); } else { - debug!("PaintTask: Ignoring requests with epoch mismatch: {:?} != {:?}", + debug!("PaintThread: Ignoring requests with epoch mismatch: {:?} != {:?}", self.current_epoch, epoch); self.compositor.ignore_buffer_requests(buffer_requests); } } - debug!("PaintTask: returning surfaces"); + debug!("PaintThread: returning surfaces"); self.compositor.assign_painted_buffers(self.id, self.current_epoch.unwrap(), replies, @@ -365,24 +365,24 @@ impl PaintTask where C: PaintListener + Send + 'static { self.paint_permission = false; } Msg::FromChrome(ChromeToPaintMsg::CollectReports(ref channel)) => { - // FIXME(njn): should eventually measure the paint task. + // FIXME(njn): should eventually measure the paint thread. channel.send(Vec::new()) } Msg::FromLayout(LayoutToPaintMsg::Exit(ref response_channel)) => { - // Ask the compositor to remove any layers it is holding for this paint task. + // Ask the compositor to remove any layers it is holding for this paint thread. // FIXME(mrobinson): This can probably move back to the constellation now. - self.compositor.notify_paint_task_exiting(self.id); + self.compositor.notify_paint_thread_exiting(self.id); - debug!("PaintTask: Exiting."); + debug!("PaintThread: Exiting."); let _ = response_channel.send(()); break; } Msg::FromChrome(ChromeToPaintMsg::Exit) => { - // Ask the compositor to remove any layers it is holding for this paint task. + // Ask the compositor to remove any layers it is holding for this paint thread. // FIXME(mrobinson): This can probably move back to the constellation now. - self.compositor.notify_paint_task_exiting(self.id); + self.compositor.notify_paint_thread_exiting(self.id); - debug!("PaintTask: Exiting."); + debug!("PaintThread: Exiting."); break; } } @@ -546,7 +546,7 @@ struct WorkerThreadProxy { impl WorkerThreadProxy { fn spawn(native_display: Option, - font_cache_task: FontCacheTask, + font_cache_thread: FontCacheThread, time_profiler_chan: time::ProfilerChan) -> Vec { let thread_count = if opts::get().gpu_painting { @@ -557,13 +557,13 @@ impl WorkerThreadProxy { (0..thread_count).map(|_| { let (from_worker_sender, from_worker_receiver) = channel(); let (to_worker_sender, to_worker_receiver) = channel(); - let font_cache_task = font_cache_task.clone(); + let font_cache_thread = font_cache_thread.clone(); let time_profiler_chan = time_profiler_chan.clone(); - task::spawn_named("PaintWorker".to_owned(), move || { + thread::spawn_named("PaintWorker".to_owned(), move || { let mut worker_thread = WorkerThread::new(from_worker_sender, to_worker_receiver, native_display, - font_cache_task, + font_cache_thread, time_profiler_chan); worker_thread.main(); }); @@ -629,7 +629,7 @@ impl WorkerThread { fn new(sender: Sender, receiver: Receiver, native_display: Option, - font_cache_task: FontCacheTask, + font_cache_thread: FontCacheThread, time_profiler_sender: time::ProfilerChan) -> WorkerThread { let gl_context = create_gl_context(native_display); @@ -637,7 +637,7 @@ impl WorkerThread { sender: sender, receiver: receiver, native_display: native_display, - font_context: box FontContext::new(font_cache_task.clone()), + font_context: box FontContext::new(font_cache_thread.clone()), time_profiler_sender: time_profiler_sender, gl_context: gl_context, } @@ -777,7 +777,7 @@ impl WorkerThread { scale: f32) -> Box { // Create an empty native surface. We mark it as not leaking - // in case it dies in transit to the compositor task. + // in case it dies in transit to the compositor thread. let width = tile.screen_rect.size.width; let height = tile.screen_rect.size.height; let mut native_surface = tile.native_surface.take().unwrap_or_else(|| { diff --git a/components/gfx_traits/paint_listener.rs b/components/gfx_traits/paint_listener.rs index 74ba4c0318d..be2f1c403f1 100644 --- a/components/gfx_traits/paint_listener.rs +++ b/components/gfx_traits/paint_listener.rs @@ -32,5 +32,5 @@ pub trait PaintListener { fn ignore_buffer_requests(&mut self, buffer_requests: Vec); // Notification that the paint task wants to exit. - fn notify_paint_task_exiting(&mut self, pipeline_id: PipelineId); + fn notify_paint_thread_exiting(&mut self, pipeline_id: PipelineId); } diff --git a/components/layout/block.rs b/components/layout/block.rs index d34ecfd546d..74f5df76e27 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -47,7 +47,7 @@ use gfx::display_list::{ClippingRegion, DisplayList}; use gfx_traits::LayerId; use incremental::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, REPAINT}; use layout_debug; -use layout_task::DISPLAY_PORT_SIZE_FACTOR; +use layout_thread::DISPLAY_PORT_SIZE_FACTOR; use model::{CollapsibleMargins, MaybeAuto, specified, specified_or_none}; use model::{IntrinsicISizes, MarginCollapseInfo}; use rustc_serialize::{Encodable, Encoder}; diff --git a/components/layout/context.rs b/components/layout/context.rs index 43c51147934..7c245408a23 100644 --- a/components/layout/context.rs +++ b/components/layout/context.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -//! Data needed by the layout task. +//! Data needed by the layout thread. #![deny(unsafe_code)] @@ -10,13 +10,13 @@ use app_units::Au; use canvas_traits::CanvasMsg; use euclid::Rect; use fnv::FnvHasher; -use gfx::font_cache_task::FontCacheTask; +use gfx::font_cache_thread::FontCacheThread; use gfx::font_context::FontContext; use gfx_traits::LayerId; use ipc_channel::ipc::{self, IpcSender}; use net_traits::image::base::Image; -use net_traits::image_cache_task::{ImageCacheChan, ImageCacheTask, ImageResponse, ImageState}; -use net_traits::image_cache_task::{UsePlaceholder}; +use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread, ImageResponse, ImageState}; +use net_traits::image_cache_thread::{UsePlaceholder}; use std::cell::{RefCell, RefMut}; use std::collections::HashMap; use std::collections::hash_state::DefaultState; @@ -59,13 +59,13 @@ fn create_or_get_local_context(shared_layout_context: &SharedLayoutContext) } context } else { - let font_cache_task = shared_layout_context.font_cache_task.lock().unwrap().clone(); + let font_cache_thread = shared_layout_context.font_cache_thread.lock().unwrap().clone(); let context = Rc::new(LocalLayoutContext { style_context: LocalStyleContext { applicable_declarations_cache: RefCell::new(ApplicableDeclarationsCache::new()), style_sharing_candidate_cache: RefCell::new(StyleSharingCandidateCache::new()), }, - font_context: RefCell::new(FontContext::new(font_cache_task)), + font_context: RefCell::new(FontContext::new(font_cache_thread)), }); *r = Some(context.clone()); context @@ -78,19 +78,19 @@ pub struct SharedLayoutContext { /// Bits shared by the layout and style system. pub style_context: SharedStyleContext, - /// The shared image cache task. - pub image_cache_task: ImageCacheTask, + /// The shared image cache thread. + pub image_cache_thread: ImageCacheThread, /// A channel for the image cache to send responses to. pub image_cache_sender: Mutex, - /// Interface to the font cache task. - pub font_cache_task: Mutex, + /// Interface to the font cache thread. + pub font_cache_thread: Mutex, /// The URL. pub url: Url, - /// A channel to send canvas renderers to paint task, in order to correctly paint the layers + /// A channel to send canvas renderers to paint thread, in order to correctly paint the layers pub canvas_layers_sender: Mutex)>>, /// The visible rects for each layer, as reported to us by the compositor. @@ -131,7 +131,7 @@ impl<'a> LayoutContext<'a> { pub fn get_or_request_image(&self, url: Url, use_placeholder: UsePlaceholder) -> Option> { // See if the image is already available - let result = self.shared.image_cache_task.find_image(url.clone(), + let result = self.shared.image_cache_thread.find_image(url.clone(), use_placeholder); match result { @@ -148,7 +148,7 @@ impl<'a> LayoutContext<'a> { // Not loaded, test mode - load the image synchronously (_, true) => { let (sync_tx, sync_rx) = ipc::channel().unwrap(); - self.shared.image_cache_task.request_image(url, + self.shared.image_cache_thread.request_image(url, ImageCacheChan(sync_tx), None); match sync_rx.recv().unwrap().image_response { @@ -160,7 +160,7 @@ impl<'a> LayoutContext<'a> { // Not yet requested, async mode - request image from the cache (ImageState::NotRequested, false) => { let sender = self.shared.image_cache_sender.lock().unwrap().clone(); - self.shared.image_cache_task.request_image(url, sender, None); + self.shared.image_cache_thread.request_image(url, sender, None); None } // Image has been requested, is still pending. Return no image diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index 35c8de55fb4..0c9a767b0ad 100644 --- a/components/layout/display_list_builder.rs +++ b/components/layout/display_list_builder.rs @@ -29,7 +29,7 @@ use gfx::display_list::{GradientDisplayItem}; use gfx::display_list::{GradientStop, ImageDisplayItem, LayeredItem, LayerInfo}; use gfx::display_list::{LineDisplayItem, OpaqueNode, SolidColorDisplayItem}; use gfx::display_list::{StackingContext, TextDisplayItem, TextOrientation}; -use gfx::paint_task::THREAD_TINT_COLORS; +use gfx::paint_thread::THREAD_TINT_COLORS; use gfx::text::glyph::CharIndex; use gfx_traits::{color, ScrollPolicy}; use inline::{FIRST_FRAGMENT_OF_ELEMENT, InlineFlow, LAST_FRAGMENT_OF_ELEMENT}; @@ -37,7 +37,7 @@ use ipc_channel::ipc::{self, IpcSharedMemory}; use list_item::ListItemFlow; use model::{self, MaybeAuto, ToGfxMatrix}; use net_traits::image::base::{Image, PixelFormat}; -use net_traits::image_cache_task::UsePlaceholder; +use net_traits::image_cache_thread::UsePlaceholder; use std::default::Default; use std::sync::Arc; use std::sync::mpsc::channel; @@ -1141,7 +1141,7 @@ impl FragmentDisplayListBuilding for Fragment { FromLayoutMsg::SendPixelContents(sender))).unwrap(); let data = receiver.recv().unwrap(); - // Propagate the layer and the renderer to the paint task. + // Propagate the layer and the renderer to the paint thread. layout_context.shared.canvas_layers_sender.lock().unwrap().send( (layer_id, (*ipc_renderer).clone())).unwrap(); diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index 16082ad075a..24feec526b1 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -27,7 +27,7 @@ use model::{self, IntrinsicISizes, IntrinsicISizesContribution, MaybeAuto, speci use msg::compositor_msg::LayerType; use msg::constellation_msg::PipelineId; use net_traits::image::base::Image; -use net_traits::image_cache_task::UsePlaceholder; +use net_traits::image_cache_thread::UsePlaceholder; use rustc_serialize::{Encodable, Encoder}; use script::dom::htmlcanvaselement::HTMLCanvasData; use std::borrow::ToOwned; @@ -575,7 +575,7 @@ impl ReplacedImageFragmentInfo { } /// A fragment that represents an inline frame (iframe). This stores the pipeline ID so that the -/// size of this iframe can be communicated via the constellation to the iframe's own layout task. +/// size of this iframe can be communicated via the constellation to the iframe's own layout thread. #[derive(Clone)] pub struct IframeFragmentInfo { /// The pipeline ID of this iframe. diff --git a/components/layout/layout_debug.rs b/components/layout/layout_debug.rs index 9175b7aec89..dc1ac1db946 100644 --- a/components/layout/layout_debug.rs +++ b/components/layout/layout_debug.rs @@ -116,10 +116,10 @@ pub fn begin_trace(flow_root: FlowRef) { /// trace to disk in the current directory. The output /// file can then be viewed with an external tool. pub fn end_trace() { - let mut task_state = STATE_KEY.with(|ref r| r.borrow_mut().take().unwrap()); - assert!(task_state.scope_stack.len() == 1); - let mut root_scope = task_state.scope_stack.pop().unwrap(); - root_scope.post = json::encode(&flow::base(&*task_state.flow_root)).unwrap(); + let mut thread_state = STATE_KEY.with(|ref r| r.borrow_mut().take().unwrap()); + assert!(thread_state.scope_stack.len() == 1); + let mut root_scope = thread_state.scope_stack.pop().unwrap(); + root_scope.post = json::encode(&flow::base(&*thread_state.flow_root)).unwrap(); let result = json::encode(&root_scope).unwrap(); let mut file = File::create("layout_trace.json").unwrap(); diff --git a/components/layout/layout_task.rs b/components/layout/layout_thread.rs similarity index 92% rename from components/layout/layout_task.rs rename to components/layout/layout_thread.rs index 7c39d61db22..668d08e2c85 100644 --- a/components/layout/layout_task.rs +++ b/components/layout/layout_thread.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -//! The layout task. Performs layout on the DOM, builds display lists and sends them to be +//! The layout thread. Performs layout on the DOM, builds display lists and sends them to be //! painted. #![allow(unsafe_code)] @@ -24,20 +24,20 @@ use flow_ref::{self, FlowRef}; use fnv::FnvHasher; use gfx::display_list::{ClippingRegion, DisplayList, LayerInfo, OpaqueNode, StackingContext}; use gfx::font; -use gfx::font_cache_task::FontCacheTask; +use gfx::font_cache_thread::FontCacheThread; use gfx::font_context; -use gfx::paint_task::{LayoutToPaintMsg, PaintLayer}; +use gfx::paint_thread::{LayoutToPaintMsg, PaintLayer}; use gfx_traits::{color, LayerId, ScrollPolicy}; use incremental::{LayoutDamageComputation, REFLOW, REFLOW_ENTIRE_DOCUMENT, REPAINT}; use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; use ipc_channel::router::ROUTER; use layout_debug; -use layout_traits::LayoutTaskFactory; +use layout_traits::LayoutThreadFactory; use log; use msg::ParseErrorReporter; use msg::compositor_msg::Epoch; use msg::constellation_msg::{ConstellationChan, Failure, PipelineId}; -use net_traits::image_cache_task::{ImageCacheChan, ImageCacheResult, ImageCacheTask}; +use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheResult, ImageCacheThread}; use parallel; use profile_traits::mem::{self, Report, ReportKind, ReportsChan}; use profile_traits::time::{TimerMetadataFrameType, TimerMetadataReflowType}; @@ -47,7 +47,7 @@ use query::{process_node_geometry_request, process_offset_parent_query, process_ use script::dom::node::OpaqueStyleAndLayoutData; use script::layout_interface::Animation; use script::layout_interface::{LayoutRPC, OffsetParentResponse}; -use script::layout_interface::{Msg, NewLayoutTaskInfo, Reflow, ReflowGoal, ReflowQueryType}; +use script::layout_interface::{Msg, NewLayoutThreadInfo, Reflow, ReflowGoal, ReflowQueryType}; use script::layout_interface::{ScriptLayoutChan, ScriptReflow}; use script::reporter::CSSErrorReporter; use script_traits::ConstellationControlMsg; @@ -77,8 +77,8 @@ use util::ipc::OptionalIpcSender; use util::logical_geometry::LogicalPoint; use util::mem::HeapSizeOf; use util::opts; -use util::task; -use util::task_state; +use util::thread; +use util::thread_state; use util::workqueue::WorkQueue; use wrapper::{LayoutNode, NonOpaqueStyleAndLayoutData, ServoLayoutNode, ThreadSafeLayoutNode}; @@ -88,10 +88,10 @@ pub const DISPLAY_PORT_SIZE_FACTOR: i32 = 8; /// The number of screens we have to traverse before we decide to generate new display lists. const DISPLAY_PORT_THRESHOLD_SIZE_FACTOR: i32 = 4; -/// Mutable data belonging to the LayoutTask. +/// Mutable data belonging to the LayoutThread. /// /// This needs to be protected by a mutex so we can do fast RPCs. -pub struct LayoutTaskData { +pub struct LayoutThreadData { /// The channel on which messages can be sent to the constellation. pub constellation_chan: ConstellationChan, @@ -117,8 +117,8 @@ pub struct LayoutTaskData { pub offset_parent_response: OffsetParentResponse, } -/// Information needed by the layout task. -pub struct LayoutTask { +/// Information needed by the layout thread. +pub struct LayoutThread { /// The ID of the pipeline that we belong to. id: PipelineId, @@ -128,7 +128,7 @@ pub struct LayoutTask { /// Is the current reflow of an iframe, as opposed to a root window? is_iframe: bool, - /// The port on which we receive messages from the script task. + /// The port on which we receive messages from the script thread. port: Receiver, /// The port on which we receive messages from the constellation. @@ -140,7 +140,7 @@ pub struct LayoutTask { /// The channel on which the image cache can send messages to ourself. image_cache_sender: ImageCacheChan, - /// The port on which we receive messages from the font cache task. + /// The port on which we receive messages from the font cache thread. font_cache_receiver: Receiver<()>, /// The channel on which the font cache can send messages to us. @@ -149,10 +149,10 @@ pub struct LayoutTask { /// The channel on which messages can be sent to the constellation. constellation_chan: ConstellationChan, - /// The channel on which messages can be sent to the script task. + /// The channel on which messages can be sent to the script thread. script_chan: IpcSender, - /// The channel on which messages can be sent to the painting task. + /// The channel on which messages can be sent to the painting thread. paint_chan: OptionalIpcSender, /// The channel on which messages can be sent to the time profiler. @@ -162,12 +162,12 @@ pub struct LayoutTask { mem_profiler_chan: mem::ProfilerChan, /// The channel on which messages can be sent to the image cache. - image_cache_task: ImageCacheTask, + image_cache_thread: ImageCacheThread, - /// Public interface to the font cache task. - font_cache_task: FontCacheTask, + /// Public interface to the font cache thread. + font_cache_thread: FontCacheThread, - /// Is this the first reflow in this LayoutTask? + /// Is this the first reflow in this LayoutThread? first_reflow: bool, /// To receive a canvas renderer associated to a layer, this message is propagated @@ -213,19 +213,19 @@ pub struct LayoutTask { viewport_size: Size2D, /// A mutex to allow for fast, read-only RPC of layout's internal data - /// structures, while still letting the LayoutTask modify them. + /// structures, while still letting the LayoutThread modify them. /// /// All the other elements of this struct are read-only. - rw_data: Arc>, + rw_data: Arc>, /// The CSS error reporter for all CSS loaded in this layout thread error_reporter: CSSErrorReporter, } -impl LayoutTaskFactory for LayoutTask { - /// Spawns a new layout task. - fn create(_phantom: Option<&mut LayoutTask>, +impl LayoutThreadFactory for LayoutThread { + /// Spawns a new layout thread. + fn create(_phantom: Option<&mut LayoutThread>, id: PipelineId, url: Url, is_iframe: bool, @@ -235,19 +235,19 @@ impl LayoutTaskFactory for LayoutTask { failure_msg: Failure, script_chan: IpcSender, paint_chan: OptionalIpcSender, - image_cache_task: ImageCacheTask, - font_cache_task: FontCacheTask, + image_cache_thread: ImageCacheThread, + font_cache_thread: FontCacheThread, time_profiler_chan: time::ProfilerChan, mem_profiler_chan: mem::ProfilerChan, shutdown_chan: IpcSender<()>, content_process_shutdown_chan: IpcSender<()>) { let ConstellationChan(con_chan) = constellation_chan.clone(); - task::spawn_named_with_send_on_failure(format!("LayoutTask {:?}", id), - task_state::LAYOUT, + thread::spawn_named_with_send_on_failure(format!("LayoutThread {:?}", id), + thread_state::LAYOUT, move || { - { // Ensures layout task is destroyed before we send shutdown message + { // Ensures layout thread is destroyed before we send shutdown message let sender = chan.sender(); - let layout = LayoutTask::new(id, + let layout = LayoutThread::new(id, url, is_iframe, chan.receiver(), @@ -255,8 +255,8 @@ impl LayoutTaskFactory for LayoutTask { constellation_chan, script_chan, paint_chan, - image_cache_task, - font_cache_task, + image_cache_thread, + font_cache_thread, time_profiler_chan, mem_profiler_chan.clone()); @@ -271,20 +271,20 @@ impl LayoutTaskFactory for LayoutTask { } } -/// The `LayoutTask` `rw_data` lock must remain locked until the first reflow, +/// The `LayoutThread` `rw_data` lock must remain locked until the first reflow, /// as RPC calls don't make sense until then. Use this in combination with -/// `LayoutTask::lock_rw_data` and `LayoutTask::return_rw_data`. +/// `LayoutThread::lock_rw_data` and `LayoutThread::return_rw_data`. pub enum RWGuard<'a> { - /// If the lock was previously held, from when the task started. - Held(MutexGuard<'a, LayoutTaskData>), + /// If the lock was previously held, from when the thread started. + Held(MutexGuard<'a, LayoutThreadData>), /// If the lock was just used, and has been returned since there has been /// a reflow already. - Used(MutexGuard<'a, LayoutTaskData>), + Used(MutexGuard<'a, LayoutThreadData>), } impl<'a> Deref for RWGuard<'a> { - type Target = LayoutTaskData; - fn deref(&self) -> &LayoutTaskData { + type Target = LayoutThreadData; + fn deref(&self) -> &LayoutThreadData { match *self { RWGuard::Held(ref x) => &**x, RWGuard::Used(ref x) => &**x, @@ -293,7 +293,7 @@ impl<'a> Deref for RWGuard<'a> { } impl<'a> DerefMut for RWGuard<'a> { - fn deref_mut(&mut self) -> &mut LayoutTaskData { + fn deref_mut(&mut self) -> &mut LayoutThreadData { match *self { RWGuard::Held(ref mut x) => &mut **x, RWGuard::Used(ref mut x) => &mut **x, @@ -302,8 +302,8 @@ impl<'a> DerefMut for RWGuard<'a> { } struct RwData<'a, 'b: 'a> { - rw_data: &'b Arc>, - possibly_locked_rw_data: &'a mut Option>, + rw_data: &'b Arc>, + possibly_locked_rw_data: &'a mut Option>, } impl<'a, 'b: 'a> RwData<'a, 'b> { @@ -333,20 +333,20 @@ impl<'a, 'b: 'a> RwData<'a, 'b> { fn add_font_face_rules(stylesheet: &Stylesheet, device: &Device, - font_cache_task: &FontCacheTask, + font_cache_thread: &FontCacheThread, font_cache_sender: &IpcSender<()>, outstanding_web_fonts_counter: &Arc) { for font_face in stylesheet.effective_rules(&device).font_face() { for source in &font_face.sources { if opts::get().load_webfonts_synchronously { let (sender, receiver) = ipc::channel().unwrap(); - font_cache_task.add_web_font(font_face.family.clone(), + font_cache_thread.add_web_font(font_face.family.clone(), (*source).clone(), sender); receiver.recv().unwrap(); } else { outstanding_web_fonts_counter.fetch_add(1, Ordering::SeqCst); - font_cache_task.add_web_font(font_face.family.clone(), + font_cache_thread.add_web_font(font_face.family.clone(), (*source).clone(), (*font_cache_sender).clone()); } @@ -354,8 +354,8 @@ fn add_font_face_rules(stylesheet: &Stylesheet, } } -impl LayoutTask { - /// Creates a new `LayoutTask` structure. +impl LayoutThread { + /// Creates a new `LayoutThread` structure. fn new(id: PipelineId, url: Url, is_iframe: bool, @@ -364,16 +364,16 @@ impl LayoutTask { constellation_chan: ConstellationChan, script_chan: IpcSender, paint_chan: OptionalIpcSender, - image_cache_task: ImageCacheTask, - font_cache_task: FontCacheTask, + image_cache_thread: ImageCacheThread, + font_cache_thread: FontCacheThread, time_profiler_chan: time::ProfilerChan, mem_profiler_chan: mem::ProfilerChan) - -> LayoutTask { + -> LayoutThread { let device = Device::new( MediaType::Screen, opts::get().initial_window_size.as_f32() * ScaleFactor::new(1.0)); let parallel_traversal = if opts::get().layout_threads != 1 { - Some(WorkQueue::new("LayoutWorker", task_state::LAYOUT, + Some(WorkQueue::new("LayoutWorker", thread_state::LAYOUT, opts::get().layout_threads)) } else { None @@ -386,12 +386,12 @@ impl LayoutTask { // Proxy IPC messages from the pipeline to the layout thread. let pipeline_receiver = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(pipeline_port); - // Ask the router to proxy IPC messages from the image cache task to the layout thread. + // Ask the router to proxy IPC messages from the image cache thread to the layout thread. let (ipc_image_cache_sender, ipc_image_cache_receiver) = ipc::channel().unwrap(); let image_cache_receiver = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_image_cache_receiver); - // Ask the router to proxy IPC messages from the font cache task to the layout thread. + // Ask the router to proxy IPC messages from the font cache thread to the layout thread. let (ipc_font_cache_sender, ipc_font_cache_receiver) = ipc::channel().unwrap(); let font_cache_receiver = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_font_cache_receiver); @@ -401,12 +401,12 @@ impl LayoutTask { for stylesheet in &*USER_OR_USER_AGENT_STYLESHEETS { add_font_face_rules(stylesheet, &stylist.device, - &font_cache_task, + &font_cache_thread, &ipc_font_cache_sender, &outstanding_web_fonts_counter); } - LayoutTask { + LayoutThread { id: id, url: RefCell::new(url), is_iframe: is_iframe, @@ -417,8 +417,8 @@ impl LayoutTask { paint_chan: paint_chan, time_profiler_chan: time_profiler_chan, mem_profiler_chan: mem_profiler_chan, - image_cache_task: image_cache_task, - font_cache_task: font_cache_task, + image_cache_thread: image_cache_thread, + font_cache_thread: font_cache_thread, first_reflow: true, image_cache_receiver: image_cache_receiver, image_cache_sender: ImageCacheChan(ipc_image_cache_sender), @@ -438,7 +438,7 @@ impl LayoutTask { epoch: Epoch(0), viewport_size: Size2D::new(Au(0), Au(0)), rw_data: Arc::new(Mutex::new( - LayoutTaskData { + LayoutThreadData { constellation_chan: constellation_chan, stacking_context: None, stylist: stylist, @@ -467,7 +467,7 @@ impl LayoutTask { // Create a layout context for use in building display lists, hit testing, &c. fn build_shared_layout_context(&self, - rw_data: &LayoutTaskData, + rw_data: &LayoutThreadData, screen_size_changed: bool, url: &Url, goal: ReflowGoal) @@ -484,16 +484,16 @@ impl LayoutTask { expired_animations: self.expired_animations.clone(), error_reporter: self.error_reporter.clone(), }, - image_cache_task: self.image_cache_task.clone(), + image_cache_thread: self.image_cache_thread.clone(), image_cache_sender: Mutex::new(self.image_cache_sender.clone()), - font_cache_task: Mutex::new(self.font_cache_task.clone()), + font_cache_thread: Mutex::new(self.font_cache_thread.clone()), canvas_layers_sender: Mutex::new(self.canvas_layers_sender.clone()), url: (*url).clone(), visible_rects: self.visible_rects.clone(), } } - /// Receives and dispatches messages from the script and constellation tasks + /// Receives and dispatches messages from the script and constellation threads fn handle_request<'a, 'b>(&mut self, possibly_locked_rw_data: &mut RwData<'a, 'b>) -> bool { enum Request { FromPipeline(LayoutControlMsg), @@ -584,7 +584,7 @@ impl LayoutTask { true } - /// Receives and dispatches messages from other tasks. + /// Receives and dispatches messages from other threads. fn handle_request_helper<'a, 'b>(&mut self, request: Msg, possibly_locked_rw_data: &mut RwData<'a, 'b>) @@ -628,8 +628,8 @@ impl LayoutTask { let outstanding_web_fonts = self.outstanding_web_fonts.load(Ordering::SeqCst); sender.send(outstanding_web_fonts != 0).unwrap(); }, - Msg::CreateLayoutTask(info) => { - self.create_layout_task(info) + Msg::CreateLayoutThread(info) => { + self.create_layout_thread(info) } Msg::SetFinalUrl(final_url) => { *self.url.borrow_mut() = final_url; @@ -658,14 +658,14 @@ impl LayoutTask { let stacking_context = rw_data.stacking_context.as_ref(); let formatted_url = &format!("url({})", *self.url.borrow()); reports.push(Report { - path: path![formatted_url, "layout-task", "display-list"], + path: path![formatted_url, "layout-thread", "display-list"], kind: ReportKind::ExplicitJemallocHeapSize, size: stacking_context.map_or(0, |sc| sc.heap_size_of_children()), }); - // The LayoutTask has a context in TLS... + // The LayoutThread has a context in TLS... reports.push(Report { - path: path![formatted_url, "layout-task", "local-context"], + path: path![formatted_url, "layout-thread", "local-context"], kind: ReportKind::ExplicitJemallocHeapSize, size: heap_size_of_local_context(), }); @@ -686,8 +686,8 @@ impl LayoutTask { reports_chan.send(reports); } - fn create_layout_task(&self, info: NewLayoutTaskInfo) { - LayoutTaskFactory::create(None::<&mut LayoutTask>, + fn create_layout_thread(&self, info: NewLayoutThreadInfo) { + LayoutThreadFactory::create(None::<&mut LayoutThread>, info.id, info.url.clone(), info.is_parent, @@ -697,8 +697,8 @@ impl LayoutTask { info.failure, info.script_chan.clone(), info.paint_chan.to::(), - self.image_cache_task.clone(), - self.font_cache_task.clone(), + self.image_cache_thread.clone(), + self.font_cache_thread.clone(), self.time_profiler_chan.clone(), self.mem_profiler_chan.clone(), info.layout_shutdown_chan, @@ -717,7 +717,7 @@ impl LayoutTask { } } Msg::ExitNow => { - debug!("layout task is exiting..."); + debug!("layout thread is exiting..."); self.exit_now(); break } @@ -731,7 +731,7 @@ impl LayoutTask { } } - /// Shuts down the layout task now. If there are any DOM nodes left, layout will now (safely) + /// Shuts down the layout thread now. If there are any DOM nodes left, layout will now (safely) /// crash. fn exit_now(&mut self) { if let Some(ref mut traversal) = self.parallel_traversal { @@ -753,7 +753,7 @@ impl LayoutTask { if stylesheet.is_effective_for_device(&rw_data.stylist.device) { add_font_face_rules(&*stylesheet, &rw_data.stylist.device, - &self.font_cache_task, + &self.font_cache_thread, &self.font_cache_sender, &self.outstanding_web_fonts); } @@ -829,7 +829,7 @@ impl LayoutTask { data: &Reflow, layout_root: &mut FlowRef, shared_layout_context: &mut SharedLayoutContext, - rw_data: &mut LayoutTaskData) { + rw_data: &mut LayoutThreadData) { let writing_mode = flow::base(&**layout_root).writing_mode; let (metadata, sender) = (self.profiler_metadata(), self.time_profiler_chan.clone()); profile(time::ProfilerCategory::LayoutDispListBuild, @@ -912,7 +912,7 @@ impl LayoutTask { }); } - /// The high-level routine that performs layout tasks. + /// The high-level routine that performs layout threads. fn handle_reflow<'a, 'b>(&mut self, data: &ScriptReflow, possibly_locked_rw_data: &mut RwData<'a, 'b>) { @@ -994,12 +994,12 @@ impl LayoutTask { let needs_reflow = viewport_size_changed && !needs_dirtying; unsafe { if needs_dirtying { - LayoutTask::dirty_all_nodes(node); + LayoutThread::dirty_all_nodes(node); } } if needs_reflow { if let Some(mut flow) = self.try_get_layout_root(node) { - LayoutTask::reflow_all_nodes(flow_ref::deref_mut(&mut flow)); + LayoutThread::reflow_all_nodes(flow_ref::deref_mut(&mut flow)); } } @@ -1052,7 +1052,7 @@ impl LayoutTask { self.root_flow = self.try_get_layout_root(node); } - // Send new canvas renderers to the paint task + // Send new canvas renderers to the paint thread while let Ok((layer_id, renderer)) = self.canvas_layers_receiver.try_recv() { // Just send if there's an actual renderer self.paint_chan.send(LayoutToPaintMsg::CanvasLayer(layer_id, renderer)).unwrap(); @@ -1157,7 +1157,7 @@ impl LayoutTask { .unwrap(); } - pub fn tick_animations(&mut self, rw_data: &mut LayoutTaskData) { + pub fn tick_animations(&mut self, rw_data: &mut LayoutThreadData) { let reflow_info = Reflow { goal: ReflowGoal::ForDisplay, page_clip_rect: MAX_RECT, @@ -1210,7 +1210,7 @@ impl LayoutTask { fn perform_post_style_recalc_layout_passes(&mut self, data: &Reflow, - rw_data: &mut LayoutTaskData, + rw_data: &mut LayoutThreadData, layout_context: &mut SharedLayoutContext) { if let Some(mut root_flow) = self.root_flow.clone() { // Kick off animations if any were triggered, expire completed ones. @@ -1251,11 +1251,11 @@ impl LayoutTask { match self.parallel_traversal { None => { // Sequential mode. - LayoutTask::solve_constraints(&mut root_flow, &layout_context) + LayoutThread::solve_constraints(&mut root_flow, &layout_context) } Some(ref mut parallel) => { // Parallel mode. - LayoutTask::solve_constraints_parallel(parallel, + LayoutThread::solve_constraints_parallel(parallel, &mut root_flow, profiler_metadata, self.time_profiler_chan.clone(), @@ -1270,7 +1270,7 @@ impl LayoutTask { fn perform_post_main_layout_passes(&mut self, data: &Reflow, - rw_data: &mut LayoutTaskData, + rw_data: &mut LayoutThreadData, layout_context: &mut SharedLayoutContext) { // Build the display list if necessary, and send it to the painter. if let Some(mut root_flow) = self.root_flow.clone() { @@ -1307,11 +1307,11 @@ impl LayoutTask { flow::mut_base(flow).restyle_damage.insert(REFLOW | REPAINT); for child in flow::child_iter(flow) { - LayoutTask::reflow_all_nodes(child); + LayoutThread::reflow_all_nodes(child); } } - /// Handles a message to destroy layout data. Layout data must be destroyed on *this* task + /// Handles a message to destroy layout data. Layout data must be destroyed on *this* thread /// because the struct type is transmuted to a different type on the script side. unsafe fn handle_reap_style_and_layout_data(&self, data: OpaqueStyleAndLayoutData) { let non_opaque: NonOpaqueStyleAndLayoutData = transmute(data.ptr); diff --git a/components/layout/lib.rs b/components/layout/lib.rs index 2b17e3b677d..5a3197dd996 100644 --- a/components/layout/lib.rs +++ b/components/layout/lib.rs @@ -78,7 +78,7 @@ mod fragment; mod generated_content; mod incremental; mod inline; -pub mod layout_task; +pub mod layout_thread; mod list_item; mod model; mod multicol; diff --git a/components/layout/query.rs b/components/layout/query.rs index 1b1f0907a4b..ab28e6c49d8 100644 --- a/components/layout/query.rs +++ b/components/layout/query.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -//! Utilities for querying the layout, as needed by the layout task. +//! Utilities for querying the layout, as needed by the layout thread. use app_units::Au; use construct::ConstructionResult; @@ -12,7 +12,7 @@ use flow; use flow_ref::FlowRef; use fragment::{Fragment, FragmentBorderBoxIterator, SpecificFragmentInfo}; use gfx::display_list::{DisplayItemMetadata, OpaqueNode}; -use layout_task::LayoutTaskData; +use layout_thread::LayoutThreadData; use msg::constellation_msg::ConstellationChan; use opaque_node::OpaqueNodeMethods; use script::layout_interface::{ContentBoxResponse, ContentBoxesResponse, NodeGeometryResponse}; @@ -32,7 +32,7 @@ use util::cursor::Cursor; use util::logical_geometry::WritingMode; use wrapper::{LayoutNode, ThreadSafeLayoutNode}; -pub struct LayoutRPCImpl(pub Arc>); +pub struct LayoutRPCImpl(pub Arc>); impl LayoutRPC for LayoutRPCImpl { diff --git a/components/layout/traversal.rs b/components/layout/traversal.rs index c42ba491732..2bda2ce3a7f 100644 --- a/components/layout/traversal.rs +++ b/components/layout/traversal.rs @@ -15,7 +15,7 @@ use std::mem; use style::context::StyleContext; use style::matching::MatchMethods; use style::traversal::{DomTraversalContext, STYLE_BLOOM}; -use style::traversal::{put_task_local_bloom_filter, recalc_style_at}; +use style::traversal::{put_thread_local_bloom_filter, recalc_style_at}; use util::opts; use util::tid::tid; use wrapper::{LayoutNode, ThreadSafeLayoutNode}; @@ -57,7 +57,7 @@ impl<'lc, 'ln, N: LayoutNode<'ln>> DomTraversalContext<'ln, N> for RecalcStyleAn // // [1] For example, the WorkQueue type needs to be parameterized on the concrete type of // DomTraversalContext::SharedContext, and the WorkQueue lifetime is similar to that of the - // LayoutTask, generally much longer than that of a given SharedLayoutContext borrow. + // LayoutThread, generally much longer than that of a given SharedLayoutContext borrow. let shared_lc: &'lc SharedLayoutContext = unsafe { mem::transmute(shared) }; RecalcStyleAndConstructFlows { context: LayoutContext::new(shared_lc), @@ -120,13 +120,13 @@ fn construct_flows_at<'a, 'ln, N: LayoutNode<'ln>>(context: &'a LayoutContext<'a match node.layout_parent_node(root) { None => { debug!("[{}] - {:X}, and deleting BF.", tid(), unsafe_layout_node.0); - // If this is the reflow root, eat the task-local bloom filter. + // If this is the reflow root, eat the thread-local bloom filter. } Some(parent) => { // Otherwise, put it back, but remove this node. node.remove_from_bloom_filter(&mut *bf); let unsafe_parent = parent.to_unsafe(); - put_task_local_bloom_filter(bf, &unsafe_parent, &context.shared_context()); + put_thread_local_bloom_filter(bf, &unsafe_parent, &context.shared_context()); }, }; } diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index aa947937d0b..31a9d040ca3 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -16,7 +16,7 @@ //! onto these objects and cause use-after-free. //! //! When implementing wrapper functions, be careful that you do not touch the borrow flags, or you -//! will race and cause spurious task failure. (Note that I do not believe these races are +//! will race and cause spurious thread failure. (Note that I do not believe these races are //! exploitable, but they'll result in brokenness nonetheless.) //! //! Rules of the road for this file: diff --git a/components/layout_traits/lib.rs b/components/layout_traits/lib.rs index 065fbf0192a..fddf5fe8b11 100644 --- a/components/layout_traits/lib.rs +++ b/components/layout_traits/lib.rs @@ -21,11 +21,11 @@ extern crate util; // The traits are here instead of in layout so // that these modules won't have to depend on layout. -use gfx::font_cache_task::FontCacheTask; -use gfx::paint_task::LayoutToPaintMsg; +use gfx::font_cache_thread::FontCacheThread; +use gfx::paint_thread::LayoutToPaintMsg; use ipc_channel::ipc::{IpcReceiver, IpcSender}; use msg::constellation_msg::{ConstellationChan, Failure, PipelineId}; -use net_traits::image_cache_task::ImageCacheTask; +use net_traits::image_cache_thread::ImageCacheThread; use profile_traits::{mem, time}; use script_traits::LayoutMsg as ConstellationMsg; use script_traits::{LayoutControlMsg, ConstellationControlMsg, OpaqueScriptLayoutChannel}; @@ -36,9 +36,9 @@ use util::ipc::OptionalIpcSender; #[derive(Clone, Deserialize, Serialize)] pub struct LayoutControlChan(pub IpcSender); -// A static method creating a layout task +// A static method creating a layout thread // Here to remove the compositor -> layout dependency -pub trait LayoutTaskFactory { +pub trait LayoutThreadFactory { // FIXME: use a proper static method fn create(_phantom: Option<&mut Self>, id: PipelineId, @@ -50,8 +50,8 @@ pub trait LayoutTaskFactory { failure_msg: Failure, script_chan: IpcSender, layout_to_paint_chan: OptionalIpcSender, - image_cache_task: ImageCacheTask, - font_cache_task: FontCacheTask, + image_cache_thread: ImageCacheThread, + font_cache_thread: FontCacheThread, time_profiler_chan: time::ProfilerChan, mem_profiler_chan: mem::ProfilerChan, shutdown_chan: IpcSender<()>, diff --git a/components/msg/constellation_msg.rs b/components/msg/constellation_msg.rs index 570e9e1c684..878a8b1e7a6 100644 --- a/components/msg/constellation_msg.rs +++ b/components/msg/constellation_msg.rs @@ -42,7 +42,7 @@ pub enum IFrameSandboxState { IFrameUnsandboxed } -// We pass this info to various tasks, so it lives in a separate, cloneable struct. +// We pass this info to various threads, so it lives in a separate, cloneable struct. #[derive(Clone, Copy, Deserialize, Serialize)] pub struct Failure { pub pipeline_id: PipelineId, @@ -339,7 +339,7 @@ pub struct Image { pub bytes: IpcSharedMemory, } -/// Similar to net::resource_task::LoadData +/// Similar to net::resource_thread::LoadData /// can be passed to LoadUrl to load a page with GET/POST /// parameters or headers #[derive(Clone, Deserialize, Serialize)] diff --git a/components/net/about_loader.rs b/components/net/about_loader.rs index af9b43bb6ce..ec6865e131a 100644 --- a/components/net/about_loader.rs +++ b/components/net/about_loader.rs @@ -9,7 +9,7 @@ use hyper::mime::{Mime, SubLevel, TopLevel}; use mime_classifier::MIMEClassifier; use net_traits::ProgressMsg::Done; use net_traits::{LoadConsumer, LoadData, Metadata}; -use resource_task::{CancellationListener, send_error, start_sending_sniffed_opt}; +use resource_thread::{CancellationListener, send_error, start_sending_sniffed_opt}; use std::sync::Arc; use url::Url; use util::resource_files::resources_dir_path; diff --git a/components/net/data_loader.rs b/components/net/data_loader.rs index 3c3bcaa10c5..f8386451deb 100644 --- a/components/net/data_loader.rs +++ b/components/net/data_loader.rs @@ -6,7 +6,7 @@ use hyper::mime::{Mime, TopLevel, SubLevel, Attr, Value}; use mime_classifier::MIMEClassifier; use net_traits::ProgressMsg::{Done, Payload}; use net_traits::{LoadConsumer, LoadData, Metadata}; -use resource_task::{CancellationListener, send_error, start_sending_sniffed_opt}; +use resource_thread::{CancellationListener, send_error, start_sending_sniffed_opt}; use rustc_serialize::base64::FromBase64; use std::sync::Arc; use url::SchemeData; @@ -16,10 +16,10 @@ pub fn factory(load_data: LoadData, senders: LoadConsumer, classifier: Arc, cancel_listener: CancellationListener) { - // NB: we don't spawn a new task. + // NB: we don't spawn a new thread. // Hypothesis: data URLs are too small for parallel base64 etc. to be worth it. // Should be tested at some point. - // Left in separate function to allow easy moving to a task, if desired. + // Left in separate function to allow easy moving to a thread, if desired. load(load_data, senders, classifier, cancel_listener) } diff --git a/components/net/fetch/cors_cache.rs b/components/net/fetch/cors_cache.rs index 65c42cebe69..65d36d0bb06 100644 --- a/components/net/fetch/cors_cache.rs +++ b/components/net/fetch/cors_cache.rs @@ -196,8 +196,8 @@ impl CORSCache for BasicCORSCache { } } -/// Various messages that can be sent to a CORSCacheTask -pub enum CORSCacheTaskMsg { +/// Various messages that can be sent to a CORSCacheThread +pub enum CORSCacheThreadMsg { Clear(CacheRequestDetails, Sender<()>), Cleanup(Sender<()>), MatchHeader(CacheRequestDetails, String, Sender), @@ -208,119 +208,119 @@ pub enum CORSCacheTaskMsg { ExitMsg } -/// A Sender to a CORSCacheTask +/// A Sender to a CORSCacheThread /// /// This can be used as a CORS Cache. /// The methods on this type block until they can run, and it behaves similar to a mutex -pub type CORSCacheSender = Sender; +pub type CORSCacheSender = Sender; impl CORSCache for CORSCacheSender { fn clear (&mut self, request: CacheRequestDetails) { let (tx, rx) = channel(); - let _ = self.send(CORSCacheTaskMsg::Clear(request, tx)); + let _ = self.send(CORSCacheThreadMsg::Clear(request, tx)); let _ = rx.recv(); } fn cleanup(&mut self) { let (tx, rx) = channel(); - let _ = self.send(CORSCacheTaskMsg::Cleanup(tx)); + let _ = self.send(CORSCacheThreadMsg::Cleanup(tx)); let _ = rx.recv(); } fn match_header(&mut self, request: CacheRequestDetails, header_name: &str) -> bool { let (tx, rx) = channel(); - let _ = self.send(CORSCacheTaskMsg::MatchHeader(request, header_name.to_owned(), tx)); + let _ = self.send(CORSCacheThreadMsg::MatchHeader(request, header_name.to_owned(), tx)); rx.recv().unwrap_or(false) } fn match_header_and_update(&mut self, request: CacheRequestDetails, header_name: &str, new_max_age: u32) -> bool { let (tx, rx) = channel(); - let _ = self.send(CORSCacheTaskMsg::MatchHeaderUpdate(request, header_name.to_owned(), new_max_age, tx)); + let _ = self.send(CORSCacheThreadMsg::MatchHeaderUpdate(request, header_name.to_owned(), new_max_age, tx)); rx.recv().unwrap_or(false) } fn match_method(&mut self, request: CacheRequestDetails, method: Method) -> bool { let (tx, rx) = channel(); - let _ = self.send(CORSCacheTaskMsg::MatchMethod(request, method, tx)); + let _ = self.send(CORSCacheThreadMsg::MatchMethod(request, method, tx)); rx.recv().unwrap_or(false) } fn match_method_and_update(&mut self, request: CacheRequestDetails, method: Method, new_max_age: u32) -> bool { let (tx, rx) = channel(); - let _ = self.send(CORSCacheTaskMsg::MatchMethodUpdate(request, method, new_max_age, tx)); + let _ = self.send(CORSCacheThreadMsg::MatchMethodUpdate(request, method, new_max_age, tx)); rx.recv().unwrap_or(false) } fn insert(&mut self, entry: CORSCacheEntry) { let (tx, rx) = channel(); - let _ = self.send(CORSCacheTaskMsg::Insert(entry, tx)); + let _ = self.send(CORSCacheThreadMsg::Insert(entry, tx)); let _ = rx.recv(); } } -/// A simple task-based CORS Cache that can be sent messages +/// A simple thread-based CORS Cache that can be sent messages /// /// #Example /// ```ignore -/// let task = CORSCacheTask::new(); -/// let builder = TaskBuilder::new().named("XHRTask"); -/// let mut sender = task.sender(); -/// builder.spawn(move || { task.run() }); +/// let thread = CORSCacheThread::new(); +/// let builder = ThreadBuilder::new().named("XHRThread"); +/// let mut sender = thread.sender(); +/// builder.spawn(move || { thread.run() }); /// sender.insert(CORSCacheEntry::new(/* parameters here */)); /// ``` -pub struct CORSCacheTask { - receiver: Receiver, +pub struct CORSCacheThread { + receiver: Receiver, cache: BasicCORSCache, sender: CORSCacheSender } -impl CORSCacheTask { - pub fn new() -> CORSCacheTask { +impl CORSCacheThread { + pub fn new() -> CORSCacheThread { let (tx, rx) = channel(); - CORSCacheTask { + CORSCacheThread { receiver: rx, cache: BasicCORSCache(vec![]), sender: tx } } - /// Provides a sender to the cache task + /// Provides a sender to the cache thread pub fn sender(&self) -> CORSCacheSender { self.sender.clone() } - /// Runs the cache task - /// This blocks the current task, so it is advised - /// to spawn a new task for this + /// Runs the cache thread + /// This blocks the current thread, so it is advised + /// to spawn a new thread for this /// Send ExitMsg to the associated Sender to exit pub fn run(&mut self) { loop { match self.receiver.recv().unwrap() { - CORSCacheTaskMsg::Clear(request, tx) => { + CORSCacheThreadMsg::Clear(request, tx) => { self.cache.clear(request); let _ = tx.send(()); }, - CORSCacheTaskMsg::Cleanup(tx) => { + CORSCacheThreadMsg::Cleanup(tx) => { self.cache.cleanup(); let _ = tx.send(()); }, - CORSCacheTaskMsg::MatchHeader(request, header, tx) => { + CORSCacheThreadMsg::MatchHeader(request, header, tx) => { let _ = tx.send(self.cache.match_header(request, &header)); }, - CORSCacheTaskMsg::MatchHeaderUpdate(request, header, new_max_age, tx) => { + CORSCacheThreadMsg::MatchHeaderUpdate(request, header, new_max_age, tx) => { let _ = tx.send(self.cache.match_header_and_update(request, &header, new_max_age)); }, - CORSCacheTaskMsg::MatchMethod(request, method, tx) => { + CORSCacheThreadMsg::MatchMethod(request, method, tx) => { let _ = tx.send(self.cache.match_method(request, method)); }, - CORSCacheTaskMsg::MatchMethodUpdate(request, method, new_max_age, tx) => { + CORSCacheThreadMsg::MatchMethodUpdate(request, method, new_max_age, tx) => { let _ = tx.send(self.cache.match_method_and_update(request, method, new_max_age)); }, - CORSCacheTaskMsg::Insert(entry, tx) => { + CORSCacheThreadMsg::Insert(entry, tx) => { self.cache.insert(entry); let _ = tx.send(()); }, - CORSCacheTaskMsg::ExitMsg => break + CORSCacheThreadMsg::ExitMsg => break } } } diff --git a/components/net/fetch/request.rs b/components/net/fetch/request.rs index d0c9b964785..90a28274622 100644 --- a/components/net/fetch/request.rs +++ b/components/net/fetch/request.rs @@ -17,14 +17,14 @@ use hyper::mime::{Attr, Mime, SubLevel, TopLevel, Value}; use hyper::status::StatusCode; use net_traits::response::{CacheState, HttpsState, Response, ResponseType, TerminationReason}; use net_traits::{AsyncFetchListener, Metadata}; -use resource_task::CancellationListener; +use resource_thread::CancellationListener; use std::ascii::AsciiExt; use std::cell::{Cell, RefCell}; use std::rc::Rc; use std::str::FromStr; use std::thread; use url::{Origin, Url, UrlParser}; -use util::task::spawn_named; +use util::thread::spawn_named; /// A [request context](https://fetch.spec.whatwg.org/#concept-request-context) #[derive(Copy, Clone, PartialEq)] diff --git a/components/net/file_loader.rs b/components/net/file_loader.rs index c2ab9cce9c7..cc4652c6408 100644 --- a/components/net/file_loader.rs +++ b/components/net/file_loader.rs @@ -7,8 +7,8 @@ use mime_classifier::MIMEClassifier; use mime_guess::guess_mime_type; use net_traits::ProgressMsg::{Done, Payload}; use net_traits::{LoadConsumer, LoadData, Metadata}; -use resource_task::{CancellationListener, ProgressSender}; -use resource_task::{send_error, start_sending_sniffed, start_sending_sniffed_opt}; +use resource_thread::{CancellationListener, ProgressSender}; +use resource_thread::{send_error, start_sending_sniffed, start_sending_sniffed_opt}; use std::borrow::ToOwned; use std::error::Error; use std::fs::File; @@ -16,7 +16,7 @@ use std::io::Read; use std::path::PathBuf; use std::sync::Arc; use url::Url; -use util::task::spawn_named; +use util::thread::spawn_named; static READ_SIZE: usize = 8192; diff --git a/components/net/http_loader.rs b/components/net/http_loader.rs index af05e6c9f27..88ccd286825 100644 --- a/components/net/http_loader.rs +++ b/components/net/http_loader.rs @@ -29,7 +29,7 @@ use net_traits::hosts::replace_hosts; use net_traits::{CookieSource, IncludeSubdomains, LoadConsumer, LoadContext, LoadData, Metadata}; use openssl::ssl::error::{SslError, OpensslError}; use openssl::ssl::{SSL_OP_NO_SSLV2, SSL_OP_NO_SSLV3, SSL_VERIFY_PEER, SslContext, SslMethod}; -use resource_task::{CancellationListener, send_error, start_sending_sniffed_opt}; +use resource_thread::{CancellationListener, send_error, start_sending_sniffed_opt}; use std::borrow::ToOwned; use std::boxed::FnBox; use std::collections::HashSet; @@ -41,7 +41,7 @@ use time; use time::Tm; use url::Url; use util::resource_files::resources_dir_path; -use util::task::spawn_named; +use util::thread::spawn_named; use uuid; pub type Connector = HttpsConnector; diff --git a/components/net/image_cache_task.rs b/components/net/image_cache_thread.rs similarity index 93% rename from components/net/image_cache_task.rs rename to components/net/image_cache_thread.rs index 90ade430128..98075ab3443 100644 --- a/components/net/image_cache_task.rs +++ b/components/net/image_cache_thread.rs @@ -5,10 +5,10 @@ use ipc_channel::ipc::{self, IpcSender}; use ipc_channel::router::ROUTER; use net_traits::image::base::{Image, load_from_memory}; -use net_traits::image_cache_task::ImageResponder; -use net_traits::image_cache_task::{ImageCacheChan, ImageCacheCommand, ImageCacheTask, ImageState}; -use net_traits::image_cache_task::{ImageCacheResult, ImageResponse, UsePlaceholder}; -use net_traits::{AsyncResponseTarget, ControlMsg, LoadConsumer, LoadData, ResourceTask}; +use net_traits::image_cache_thread::ImageResponder; +use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheCommand, ImageCacheThread, ImageState}; +use net_traits::image_cache_thread::{ImageCacheResult, ImageResponse, UsePlaceholder}; +use net_traits::{AsyncResponseTarget, ControlMsg, LoadConsumer, LoadData, ResourceThread}; use net_traits::{ResponseAction, LoadContext}; use std::borrow::ToOwned; use std::collections::HashMap; @@ -20,19 +20,19 @@ use std::sync::Arc; use std::sync::mpsc::{Receiver, Select, Sender, channel}; use url::Url; use util::resource_files::resources_dir_path; -use util::task::spawn_named; -use util::taskpool::TaskPool; +use util::thread::spawn_named; +use util::threadpool::ThreadPool; /// /// TODO(gw): Remaining work on image cache: /// * Make use of the prefetch support in various parts of the code. -/// * Profile time in GetImageIfAvailable - might be worth caching these results per paint / layout task. +/// * Profile time in GetImageIfAvailable - might be worth caching these results per paint / layout thread. /// /// MAYBE(Yoric): /// * For faster lookups, it might be useful to store the LoadKey in the DOM once we have performed a first load. /// Represents an image that is either being loaded -/// by the resource task, or decoded by a worker thread. +/// by the resource thread, or decoded by a worker thread. struct PendingLoad { // The bytes loaded so far. Reset to an empty vector once loading // is complete and the buffer has been transmitted to the decoder. @@ -215,7 +215,7 @@ struct ImageCache { // Receive commands from clients cmd_receiver: Receiver, - // Receive notifications from the resource task + // Receive notifications from the resource thread progress_receiver: Receiver, progress_sender: Sender, @@ -224,10 +224,10 @@ struct ImageCache { decoder_sender: Sender, // Worker threads for decoding images. - task_pool: TaskPool, + thread_pool: ThreadPool, - // Resource task handle - resource_task: ResourceTask, + // Resource thread handle + resource_thread: ResourceThread, // Images that are loading over network, or decoding. pending_loads: AllPendingLoads, @@ -239,13 +239,13 @@ struct ImageCache { placeholder_image: Option>, } -/// Message that the decoder worker threads send to main image cache task. +/// Message that the decoder worker threads send to main image cache thread. struct DecoderMsg { key: LoadKey, image: Option, } -/// The types of messages that the main image cache task receives. +/// The types of messages that the main image cache thread receives. enum SelectResult { Command(ImageCacheCommand), Progress(ResourceLoadInfo), @@ -338,7 +338,7 @@ impl ImageCache { None } - // Handle progress messages from the resource task + // Handle progress messages from the resource thread fn handle_progress(&mut self, msg: ResourceLoadInfo) { match (msg.action, msg.key) { (ResponseAction::HeadersAvailable(_), _) => {} @@ -355,7 +355,7 @@ impl ImageCache { let bytes = mem::replace(&mut pending_load.bytes, vec!()); let sender = self.decoder_sender.clone(); - self.task_pool.execute(move || { + self.thread_pool.execute(move || { let image = load_from_memory(&bytes); let msg = DecoderMsg { key: key, @@ -423,7 +423,7 @@ impl ImageCache { match cache_result { CacheResult::Miss => { // A new load request! Request the load from - // the resource task. + // the resource thread. let load_data = LoadData::new(LoadContext::Image, (*ref_url).clone(), None); let (action_sender, action_receiver) = ipc::channel().unwrap(); let response_target = AsyncResponseTarget { @@ -440,7 +440,7 @@ impl ImageCache { key: load_key, }).unwrap(); }); - self.resource_task.send(msg).unwrap(); + self.resource_thread.send(msg).unwrap(); } CacheResult::Hit => { // Request is already on its way. @@ -452,7 +452,7 @@ impl ImageCache { } /// Create a new image cache. -pub fn new_image_cache_task(resource_task: ResourceTask) -> ImageCacheTask { +pub fn new_image_cache_thread(resource_thread: ResourceThread) -> ImageCacheThread { let (ipc_command_sender, ipc_command_receiver) = ipc::channel().unwrap(); let (progress_sender, progress_receiver) = channel(); let (decoder_sender, decoder_receiver) = channel(); @@ -480,15 +480,15 @@ pub fn new_image_cache_task(resource_task: ResourceTask) -> ImageCacheTask { progress_receiver: progress_receiver, decoder_sender: decoder_sender, decoder_receiver: decoder_receiver, - task_pool: TaskPool::new(4), + thread_pool: ThreadPool::new(4), pending_loads: AllPendingLoads::new(), completed_loads: HashMap::new(), - resource_task: resource_task, + resource_thread: resource_thread, placeholder_image: placeholder_image, }; cache.run(); }); - ImageCacheTask::new(ipc_command_sender) + ImageCacheThread::new(ipc_command_sender) } diff --git a/components/net/lib.rs b/components/net/lib.rs index 10bbe28ddf3..6d8af0ffaa2 100644 --- a/components/net/lib.rs +++ b/components/net/lib.rs @@ -36,11 +36,11 @@ pub mod data_loader; pub mod file_loader; pub mod hsts; pub mod http_loader; -pub mod image_cache_task; +pub mod image_cache_thread; pub mod mime_classifier; pub mod pub_domains; -pub mod resource_task; -pub mod storage_task; +pub mod resource_thread; +pub mod storage_thread; pub mod websocket_loader; /// An implementation of the [Fetch spec](https://fetch.spec.whatwg.org/) diff --git a/components/net/resource_task.rs b/components/net/resource_thread.rs similarity index 95% rename from components/net/resource_task.rs rename to components/net/resource_thread.rs index 572374d0d4e..37a63326173 100644 --- a/components/net/resource_task.rs +++ b/components/net/resource_thread.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -//! A task that takes a URL and streams back the binary data. +//! A thread that takes a URL and streams back the binary data. use about_loader; use cookie; @@ -19,7 +19,7 @@ use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; use mime_classifier::{ApacheBugFlag, MIMEClassifier, NoSniffFlag}; use net_traits::LoadContext; use net_traits::ProgressMsg::Done; -use net_traits::{AsyncResponseTarget, Metadata, ProgressMsg, ResourceTask, ResponseAction}; +use net_traits::{AsyncResponseTarget, Metadata, ProgressMsg, ResourceThread, ResponseAction}; use net_traits::{ControlMsg, CookieSource, LoadConsumer, LoadData, LoadResponse, ResourceId}; use net_traits::{WebSocketCommunicate, WebSocketConnectData}; use std::borrow::ToOwned; @@ -30,7 +30,7 @@ use std::sync::mpsc::{Receiver, Sender, channel}; use std::sync::{Arc, RwLock}; use url::Url; use util::prefs; -use util::task::spawn_named; +use util::thread::spawn_named; use websocket_loader; pub enum ProgressSender { @@ -145,9 +145,9 @@ fn start_sending_opt(start_chan: LoadConsumer, metadata: Metadata) -> Result>) -> ResourceTask { +/// Create a ResourceThread +pub fn new_resource_thread(user_agent: String, + devtools_chan: Option>) -> ResourceThread { let hsts_preload = match preload_hsts_domains() { Some(list) => list, None => HSTSList::new() @@ -175,7 +175,7 @@ struct ResourceChannelManager { } impl ResourceChannelManager { - fn start(&mut self, control_sender: ResourceTask) { + fn start(&mut self, control_sender: ResourceThread) { loop { match self.from_client.recv().unwrap() { ControlMsg::Load(load_data, consumer, id_sender) => @@ -213,15 +213,15 @@ pub struct CancellableResource { /// If we haven't initiated any cancel requests, then the loaders ask /// the listener to remove the `ResourceId` in the `HashMap` of /// `ResourceManager` once they finish loading - resource_task: ResourceTask, + resource_thread: ResourceThread, } impl CancellableResource { - pub fn new(receiver: Receiver<()>, res_id: ResourceId, res_task: ResourceTask) -> CancellableResource { + pub fn new(receiver: Receiver<()>, res_id: ResourceId, res_thread: ResourceThread) -> CancellableResource { CancellableResource { cancel_receiver: receiver, resource_id: res_id, - resource_task: res_task, + resource_thread: res_thread, } } } @@ -264,7 +264,7 @@ impl Drop for CancellationListener { fn drop(&mut self) { if let Some(ref resource) = self.cancel_resource { // Ensure that the resource manager stops tracking this request now that it's terminated. - let _ = resource.resource_task.send(ControlMsg::Cancel(resource.resource_id)); + let _ = resource.resource_thread.send(ControlMsg::Cancel(resource.resource_id)); } } } @@ -313,7 +313,7 @@ impl ResourceManager { load_data: LoadData, consumer: LoadConsumer, id_sender: Option>, - resource_task: ResourceTask) { + resource_thread: ResourceThread) { fn from_factory(factory: fn(LoadData, LoadConsumer, Arc, CancellationListener)) -> Box from_factory(data_loader::factory), "about" => from_factory(about_loader::factory), _ => { - debug!("resource_task: no loader for scheme {}", load_data.url.scheme); + debug!("resource_thread: no loader for scheme {}", load_data.url.scheme); send_error(load_data.url, "no loader for scheme".to_owned(), consumer); return } }; - debug!("resource_task: loading url: {}", load_data.url.serialize()); + debug!("resource_thread: loading url: {}", load_data.url.serialize()); loader.call_box((load_data, consumer, diff --git a/components/net/storage_task.rs b/components/net/storage_thread.rs similarity index 89% rename from components/net/storage_task.rs rename to components/net/storage_thread.rs index d3b323697e4..7b3a1f52ca3 100644 --- a/components/net/storage_task.rs +++ b/components/net/storage_thread.rs @@ -3,23 +3,23 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; -use net_traits::storage_task::{StorageTask, StorageTaskMsg, StorageType}; +use net_traits::storage_thread::{StorageThread, StorageThreadMsg, StorageType}; use std::borrow::ToOwned; use std::collections::BTreeMap; use std::collections::HashMap; use std::sync::mpsc::channel; use url::Url; -use util::task::spawn_named; +use util::thread::spawn_named; const QUOTA_SIZE_LIMIT: usize = 5 * 1024 * 1024; -pub trait StorageTaskFactory { +pub trait StorageThreadFactory { fn new() -> Self; } -impl StorageTaskFactory for StorageTask { - /// Create a StorageTask - fn new() -> StorageTask { +impl StorageThreadFactory for StorageThread { + /// Create a StorageThread + fn new() -> StorageThread { let (chan, port) = ipc::channel().unwrap(); spawn_named("StorageManager".to_owned(), move || { StorageManager::new(port).start(); @@ -29,13 +29,13 @@ impl StorageTaskFactory for StorageTask { } struct StorageManager { - port: IpcReceiver, + port: IpcReceiver, session_data: HashMap)>, local_data: HashMap)>, } impl StorageManager { - fn new(port: IpcReceiver) -> StorageManager { + fn new(port: IpcReceiver) -> StorageManager { StorageManager { port: port, session_data: HashMap::new(), @@ -48,28 +48,28 @@ impl StorageManager { fn start(&mut self) { loop { match self.port.recv().unwrap() { - StorageTaskMsg::Length(sender, url, storage_type) => { + StorageThreadMsg::Length(sender, url, storage_type) => { self.length(sender, url, storage_type) } - StorageTaskMsg::Key(sender, url, storage_type, index) => { + StorageThreadMsg::Key(sender, url, storage_type, index) => { self.key(sender, url, storage_type, index) } - StorageTaskMsg::Keys(sender, url, storage_type) => { + StorageThreadMsg::Keys(sender, url, storage_type) => { self.keys(sender, url, storage_type) } - StorageTaskMsg::SetItem(sender, url, storage_type, name, value) => { + StorageThreadMsg::SetItem(sender, url, storage_type, name, value) => { self.set_item(sender, url, storage_type, name, value) } - StorageTaskMsg::GetItem(sender, url, storage_type, name) => { + StorageThreadMsg::GetItem(sender, url, storage_type, name) => { self.request_item(sender, url, storage_type, name) } - StorageTaskMsg::RemoveItem(sender, url, storage_type, name) => { + StorageThreadMsg::RemoveItem(sender, url, storage_type, name) => { self.remove_item(sender, url, storage_type, name) } - StorageTaskMsg::Clear(sender, url, storage_type) => { + StorageThreadMsg::Clear(sender, url, storage_type) => { self.clear(sender, url, storage_type) } - StorageTaskMsg::Exit => { + StorageThreadMsg::Exit => { break } } diff --git a/components/net/websocket_loader.rs b/components/net/websocket_loader.rs index 05665077845..461972b35f0 100644 --- a/components/net/websocket_loader.rs +++ b/components/net/websocket_loader.rs @@ -10,7 +10,7 @@ use net_traits::{WebSocketCommunicate, WebSocketConnectData, WebSocketDomAction, use std::ascii::AsciiExt; use std::sync::{Arc, Mutex}; use std::thread; -use util::task::spawn_named; +use util::thread::spawn_named; use websocket::client::receiver::Receiver; use websocket::client::request::Url; use websocket::client::sender::Sender; diff --git a/components/net_traits/image_cache_task.rs b/components/net_traits/image_cache_thread.rs similarity index 92% rename from components/net_traits/image_cache_task.rs rename to components/net_traits/image_cache_thread.rs index 5eab6e1d800..85ef01be4f6 100644 --- a/components/net_traits/image_cache_task.rs +++ b/components/net_traits/image_cache_thread.rs @@ -71,10 +71,10 @@ pub enum ImageCacheCommand { /// Synchronously check the state of an image in the cache. /// TODO(gw): Profile this on some real world sites and see /// if it's worth caching the results of this locally in each - /// layout / paint task. + /// layout / paint thread. GetImageIfAvailable(Url, UsePlaceholder, IpcSender, ImageState>>), - /// Clients must wait for a response before shutting down the ResourceTask + /// Clients must wait for a response before shutting down the ResourceThread Exit(IpcSender<()>), } @@ -84,19 +84,19 @@ pub enum UsePlaceholder { Yes, } -/// The client side of the image cache task. This can be safely cloned -/// and passed to different tasks. +/// The client side of the image cache thread. This can be safely cloned +/// and passed to different threads. #[derive(Clone, Deserialize, Serialize)] -pub struct ImageCacheTask { +pub struct ImageCacheThread { chan: IpcSender, } -/// The public API for the image cache task. -impl ImageCacheTask { +/// The public API for the image cache thread. +impl ImageCacheThread { /// Construct a new image cache - pub fn new(chan: IpcSender) -> ImageCacheTask { - ImageCacheTask { + pub fn new(chan: IpcSender) -> ImageCacheThread { + ImageCacheThread { chan: chan, } } @@ -119,7 +119,7 @@ impl ImageCacheTask { receiver.recv().unwrap() } - /// Shutdown the image cache task. + /// Shutdown the image cache thread. pub fn exit(&self) { let (response_chan, response_port) = ipc::channel().unwrap(); self.chan.send(ImageCacheCommand::Exit(response_chan)).unwrap(); diff --git a/components/net_traits/lib.rs b/components/net_traits/lib.rs index 30127935b9f..ad579d9b2d3 100644 --- a/components/net_traits/lib.rs +++ b/components/net_traits/lib.rs @@ -37,10 +37,10 @@ use util::mem::HeapSizeOf; use websocket::header; pub mod hosts; -pub mod image_cache_task; +pub mod image_cache_thread; pub mod net_error_list; pub mod response; -pub mod storage_task; +pub mod storage_thread; /// Image handling. /// @@ -160,8 +160,8 @@ pub enum LoadConsumer { Listener(AsyncResponseTarget), } -/// Handle to a resource task -pub type ResourceTask = IpcSender; +/// Handle to a resource thread +pub type ResourceThread = IpcSender; #[derive(PartialEq, Copy, Clone, Deserialize, Serialize)] pub enum IncludeSubdomains { @@ -220,10 +220,10 @@ pub enum ControlMsg { } /// Initialized but unsent request. Encapsulates everything necessary to instruct -/// the resource task to make a new request. The `load` method *must* be called before -/// destruction or the task will panic. +/// the resource thread to make a new request. The `load` method *must* be called before +/// destruction or the thread will panic. pub struct PendingAsyncLoad { - resource_task: ResourceTask, + resource_thread: ResourceThread, url: Url, pipeline: Option, guard: PendingLoadGuard, @@ -249,10 +249,10 @@ impl Drop for PendingLoadGuard { } impl PendingAsyncLoad { - pub fn new(context: LoadContext, resource_task: ResourceTask, url: Url, pipeline: Option) + pub fn new(context: LoadContext, resource_thread: ResourceThread, url: Url, pipeline: Option) -> PendingAsyncLoad { PendingAsyncLoad { - resource_task: resource_task, + resource_thread: resource_thread, url: url, pipeline: pipeline, guard: PendingLoadGuard { loaded: false, }, @@ -265,7 +265,7 @@ impl PendingAsyncLoad { self.guard.neuter(); let load_data = LoadData::new(self.context, self.url, self.pipeline); let consumer = LoadConsumer::Listener(listener); - self.resource_task.send(ControlMsg::Load(load_data, consumer, None)).unwrap(); + self.resource_thread.send(ControlMsg::Load(load_data, consumer, None)).unwrap(); } } @@ -360,12 +360,12 @@ pub enum ProgressMsg { /// Convenience function for synchronously loading a whole resource. pub fn load_whole_resource(context: LoadContext, - resource_task: &ResourceTask, + resource_thread: &ResourceThread, url: Url, pipeline_id: Option) -> Result<(Metadata, Vec), String> { let (start_chan, start_port) = ipc::channel().unwrap(); - resource_task.send(ControlMsg::Load(LoadData::new(context, url, pipeline_id), + resource_thread.send(ControlMsg::Load(LoadData::new(context, url, pipeline_id), LoadConsumer::Channel(start_chan), None)).unwrap(); let response = start_port.recv().unwrap(); diff --git a/components/net_traits/storage_task.rs b/components/net_traits/storage_thread.rs similarity index 91% rename from components/net_traits/storage_task.rs rename to components/net_traits/storage_thread.rs index af149d523e4..f544c50a059 100644 --- a/components/net_traits/storage_task.rs +++ b/components/net_traits/storage_thread.rs @@ -13,7 +13,7 @@ pub enum StorageType { /// Request operations on the storage data associated with a particular url #[derive(Deserialize, Serialize)] -pub enum StorageTaskMsg { +pub enum StorageThreadMsg { /// gets the number of key/value pairs present in the associated storage data Length(IpcSender, Url, StorageType), @@ -35,11 +35,11 @@ pub enum StorageTaskMsg { /// clears the associated storage data by removing all the key/value pairs Clear(IpcSender, Url, StorageType), - /// shut down this task + /// shut down this thread Exit } -/// Handle to a storage task -pub type StorageTask = IpcSender; +/// Handle to a storage thread +pub type StorageThread = IpcSender; diff --git a/components/plugins/lints/unrooted_must_root.rs b/components/plugins/lints/unrooted_must_root.rs index c64f127e094..b7d448d9f84 100644 --- a/components/plugins/lints/unrooted_must_root.rs +++ b/components/plugins/lints/unrooted_must_root.rs @@ -29,7 +29,7 @@ declare_lint!(UNROOTED_MUST_ROOT, Deny, /// This helps catch most situations where pointers like `JS` are used in a way that they can be invalidated by a /// GC pass. /// -/// Structs which have their own mechanism of rooting their unrooted contents (e.g. `ScriptTask`) +/// Structs which have their own mechanism of rooting their unrooted contents (e.g. `ScriptThread`) /// can be marked as `#[allow(unrooted_must_root)]`. Smart pointers which root their interior type /// can be marked as `#[allow_unrooted_interior]` pub struct UnrootedPass; diff --git a/components/profile/mem.rs b/components/profile/mem.rs index 033a1421421..129e9cca9d0 100644 --- a/components/profile/mem.rs +++ b/components/profile/mem.rs @@ -12,7 +12,7 @@ use std::borrow::ToOwned; use std::cmp::Ordering; use std::collections::HashMap; use std::thread; -use util::task::spawn_named; +use util::thread::spawn_named; use util::time::duration_from_seconds; pub struct Profiler { diff --git a/components/profile/time.rs b/components/profile/time.rs index 22f888256bf..f954912a130 100644 --- a/components/profile/time.rs +++ b/components/profile/time.rs @@ -15,7 +15,7 @@ use std::collections::BTreeMap; use std::time::Duration; use std::{thread, f64}; use std_time::precise_time_ns; -use util::task::spawn_named; +use util::thread::spawn_named; use util::time::duration_from_seconds; pub trait Formattable { diff --git a/components/profile_traits/mem.rs b/components/profile_traits/mem.rs index 9fc78febdd6..7b377a00385 100644 --- a/components/profile_traits/mem.rs +++ b/components/profile_traits/mem.rs @@ -50,7 +50,7 @@ impl ProfilerChan { // Register the memory reporter. let (reporter_sender, reporter_receiver) = ipc::channel().unwrap(); ROUTER.add_route(reporter_receiver.to_opaque(), box move |message| { - // Just injects an appropriate event into the paint task's queue. + // Just injects an appropriate event into the paint thread's queue. let request: ReporterRequest = message.to().unwrap(); channel_for_reporter.send(msg(request.reports_channel)); }); diff --git a/components/script/cors.rs b/components/script/cors.rs index 786d12d94ae..7bf5127a22e 100644 --- a/components/script/cors.rs +++ b/components/script/cors.rs @@ -20,7 +20,7 @@ use hyper::mime::{Mime, SubLevel, TopLevel}; use hyper::status::StatusClass::Success; use net_traits::{AsyncResponseListener, Metadata, ResponseAction}; use network_listener::{NetworkListener, PreInvoke}; -use script_task::ScriptChan; +use script_thread::ScriptChan; use std::ascii::AsciiExt; use std::borrow::ToOwned; use std::sync::{Arc, Mutex}; @@ -28,7 +28,7 @@ use time::{self, Timespec, now}; use unicase::UniCase; use url::{SchemeData, Url}; use util::mem::HeapSizeOf; -use util::task::spawn_named; +use util::thread::spawn_named; /// Interface for network listeners concerned with CORS checks. Proper network requests /// should be initiated from this method, based on the response provided. @@ -141,7 +141,7 @@ impl CORSRequest { }; // TODO: this exists only to make preflight check non-blocking - // perhaps should be handled by the resource task? + // perhaps should be handled by the resource thread? let req = self.clone(); spawn_named("cors".to_owned(), move || { let response = req.http_fetch(); diff --git a/components/script/devtools.rs b/components/script/devtools.rs index 8bdde1aa2d1..668c4554722 100644 --- a/components/script/devtools.rs +++ b/components/script/devtools.rs @@ -19,7 +19,7 @@ use js::jsapi::{ObjectClassName, RootedObject, RootedValue}; use js::jsval::UndefinedValue; use msg::constellation_msg::PipelineId; use page::{IterablePage, Page}; -use script_task::get_page; +use script_thread::get_page; use std::ffi::CStr; use std::rc::Rc; use std::str; diff --git a/components/script/document_loader.rs b/components/script/document_loader.rs index f5e49c46785..e0da74ae706 100644 --- a/components/script/document_loader.rs +++ b/components/script/document_loader.rs @@ -7,7 +7,7 @@ use msg::constellation_msg::PipelineId; use net_traits::AsyncResponseTarget; -use net_traits::{PendingAsyncLoad, ResourceTask, LoadContext}; +use net_traits::{PendingAsyncLoad, ResourceThread, LoadContext}; use std::sync::Arc; use url::Url; @@ -43,10 +43,10 @@ impl LoadType { #[derive(JSTraceable, HeapSizeOf)] pub struct DocumentLoader { - /// We use an `Arc` here in order to avoid file descriptor exhaustion when there + /// We use an `Arc` here in order to avoid file descriptor exhaustion when there /// are lots of iframes. #[ignore_heap_size_of = "channels are hard"] - pub resource_task: Arc, + pub resource_thread: Arc, pipeline: Option, blocking_loads: Vec, events_inhibited: bool, @@ -54,19 +54,19 @@ pub struct DocumentLoader { impl DocumentLoader { pub fn new(existing: &DocumentLoader) -> DocumentLoader { - DocumentLoader::new_with_task(existing.resource_task.clone(), None, None) + DocumentLoader::new_with_thread(existing.resource_thread.clone(), None, None) } - /// We use an `Arc` here in order to avoid file descriptor exhaustion when there + /// We use an `Arc` here in order to avoid file descriptor exhaustion when there /// are lots of iframes. - pub fn new_with_task(resource_task: Arc, + pub fn new_with_thread(resource_thread: Arc, pipeline: Option, initial_load: Option) -> DocumentLoader { let initial_loads = initial_load.into_iter().map(LoadType::PageSource).collect(); DocumentLoader { - resource_task: resource_task, + resource_thread: resource_thread, pipeline: pipeline, blocking_loads: initial_loads, events_inhibited: false, @@ -79,7 +79,7 @@ impl DocumentLoader { let context = load.to_load_context(); let url = load.url().clone(); self.blocking_loads.push(load); - PendingAsyncLoad::new(context, (*self.resource_task).clone(), url, self.pipeline) + PendingAsyncLoad::new(context, (*self.resource_thread).clone(), url, self.pipeline) } /// Create and initiate a new network request. diff --git a/components/script/dom/bindings/cell.rs b/components/script/dom/bindings/cell.rs index 50093457397..37143165a7d 100644 --- a/components/script/dom/bindings/cell.rs +++ b/components/script/dom/bindings/cell.rs @@ -7,8 +7,8 @@ use dom::bindings::trace::JSTraceable; use js::jsapi::JSTracer; use std::cell::{BorrowState, Ref, RefCell, RefMut}; -use util::task_state; -use util::task_state::SCRIPT; +use util::thread_state; +use util::thread_state::SCRIPT; /// A mutable field in the DOM. /// @@ -25,10 +25,10 @@ pub struct DOMRefCell { impl DOMRefCell { /// Return a reference to the contents. /// - /// For use in the layout task only. + /// For use in the layout thread only. #[allow(unsafe_code)] pub unsafe fn borrow_for_layout(&self) -> &T { - debug_assert!(task_state::get().is_layout()); + debug_assert!(thread_state::get().is_layout()); &*self.value.as_unsafe_cell().get() } @@ -40,7 +40,7 @@ impl DOMRefCell { pub unsafe fn borrow_for_gc_trace(&self) -> &T { // FIXME: IN_GC isn't reliable enough - doesn't catch minor GCs // https://github.com/servo/servo/issues/6389 - // debug_assert!(task_state::get().contains(SCRIPT | IN_GC)); + // debug_assert!(thread_state::get().contains(SCRIPT | IN_GC)); &*self.value.as_unsafe_cell().get() } @@ -48,7 +48,7 @@ impl DOMRefCell { /// #[allow(unsafe_code)] pub unsafe fn borrow_for_script_deallocation(&self) -> &mut T { - debug_assert!(task_state::get().contains(SCRIPT)); + debug_assert!(thread_state::get().contains(SCRIPT)); &mut *self.value.as_unsafe_cell().get() } @@ -70,7 +70,7 @@ impl DOMRefCell { /// /// Panics if this is called off the script thread. pub fn try_borrow(&self) -> Option> { - debug_assert!(task_state::get().is_script()); + debug_assert!(thread_state::get().is_script()); match self.value.borrow_state() { BorrowState::Writing => None, _ => Some(self.value.borrow()), @@ -88,17 +88,17 @@ impl DOMRefCell { /// /// Panics if this is called off the script thread. pub fn try_borrow_mut(&self) -> Option> { - debug_assert!(task_state::get().is_script()); + debug_assert!(thread_state::get().is_script()); match self.value.borrow_state() { BorrowState::Unused => Some(self.value.borrow_mut()), _ => None, } } - /// Version of the above that we use during restyle while the script task + /// Version of the above that we use during restyle while the script thread /// is blocked. pub fn borrow_mut_for_layout(&self) -> RefMut { - debug_assert!(task_state::get().is_layout()); + debug_assert!(thread_state::get().is_layout()); self.value.borrow_mut() } } diff --git a/components/script/dom/bindings/global.rs b/components/script/dom/bindings/global.rs index d3ece2ae98e..8e455d29f28 100644 --- a/components/script/dom/bindings/global.rs +++ b/components/script/dom/bindings/global.rs @@ -19,9 +19,9 @@ use js::jsapi::GetGlobalForObjectCrossCompartment; use js::jsapi::{JSContext, JSObject, JS_GetClass, MutableHandleValue}; use js::{JSCLASS_IS_DOMJSCLASS, JSCLASS_IS_GLOBAL}; use msg::constellation_msg::{ConstellationChan, PipelineId}; -use net_traits::ResourceTask; +use net_traits::ResourceThread; use profile_traits::mem; -use script_task::{CommonScriptMsg, ScriptChan, ScriptPort, ScriptTask}; +use script_thread::{CommonScriptMsg, ScriptChan, ScriptPort, ScriptThread}; use script_traits::{MsDuration, ScriptMsg as ConstellationMsg, TimerEventRequest}; use timers::{ScheduledCallback, TimerHandle}; use url::Url; @@ -65,7 +65,7 @@ impl<'a> GlobalRef<'a> { } } - /// Extract a `Window`, causing task failure if the global object is not + /// Extract a `Window`, causing thread failure if the global object is not /// a `Window`. pub fn as_window(&self) -> &window::Window { match *self { @@ -82,7 +82,7 @@ impl<'a> GlobalRef<'a> { } } - /// Get a `mem::ProfilerChan` to send messages to the memory profiler task. + /// Get a `mem::ProfilerChan` to send messages to the memory profiler thread. pub fn mem_profiler_chan(&self) -> mem::ProfilerChan { match *self { GlobalRef::Window(window) => window.mem_profiler_chan(), @@ -107,7 +107,7 @@ impl<'a> GlobalRef<'a> { } /// Get an `IpcSender` to send messages to Devtools - /// task when available. + /// thread when available. pub fn devtools_chan(&self) -> Option> { match *self { GlobalRef::Window(window) => window.devtools_chan(), @@ -115,16 +115,16 @@ impl<'a> GlobalRef<'a> { } } - /// Get the `ResourceTask` for this global scope. - pub fn resource_task(&self) -> ResourceTask { + /// Get the `ResourceThread` for this global scope. + pub fn resource_thread(&self) -> ResourceThread { match *self { GlobalRef::Window(ref window) => { let doc = window.Document(); let doc = doc.r(); let loader = doc.loader(); - (*loader.resource_task).clone() + (*loader.resource_thread).clone() } - GlobalRef::Worker(ref worker) => worker.resource_task().clone(), + GlobalRef::Worker(ref worker) => worker.resource_thread().clone(), } } @@ -154,45 +154,45 @@ impl<'a> GlobalRef<'a> { /// `ScriptChan` used to send messages to the event loop of this global's /// thread. - pub fn dom_manipulation_task_source(&self) -> Box { + pub fn dom_manipulation_thread_source(&self) -> Box { match *self { - GlobalRef::Window(ref window) => window.dom_manipulation_task_source(), + GlobalRef::Window(ref window) => window.dom_manipulation_thread_source(), GlobalRef::Worker(ref worker) => worker.script_chan(), } } /// `ScriptChan` used to send messages to the event loop of this global's /// thread. - pub fn user_interaction_task_source(&self) -> Box { + pub fn user_interaction_thread_source(&self) -> Box { match *self { - GlobalRef::Window(ref window) => window.user_interaction_task_source(), + GlobalRef::Window(ref window) => window.user_interaction_thread_source(), GlobalRef::Worker(ref worker) => worker.script_chan(), } } /// `ScriptChan` used to send messages to the event loop of this global's /// thread. - pub fn networking_task_source(&self) -> Box { + pub fn networking_thread_source(&self) -> Box { match *self { - GlobalRef::Window(ref window) => window.networking_task_source(), + GlobalRef::Window(ref window) => window.networking_thread_source(), GlobalRef::Worker(ref worker) => worker.script_chan(), } } /// `ScriptChan` used to send messages to the event loop of this global's /// thread. - pub fn history_traversal_task_source(&self) -> Box { + pub fn history_traversal_thread_source(&self) -> Box { match *self { - GlobalRef::Window(ref window) => window.history_traversal_task_source(), + GlobalRef::Window(ref window) => window.history_traversal_thread_source(), GlobalRef::Worker(ref worker) => worker.script_chan(), } } /// `ScriptChan` used to send messages to the event loop of this global's /// thread. - pub fn file_reading_task_source(&self) -> Box { + pub fn file_reading_thread_source(&self) -> Box { match *self { - GlobalRef::Window(ref window) => window.file_reading_task_source(), + GlobalRef::Window(ref window) => window.file_reading_thread_source(), GlobalRef::Worker(ref worker) => worker.script_chan(), } } @@ -207,11 +207,11 @@ impl<'a> GlobalRef<'a> { } } - /// Process a single event as if it were the next event in the task queue for + /// Process a single event as if it were the next event in the thread queue for /// this global. pub fn process_event(&self, msg: CommonScriptMsg) { match *self { - GlobalRef::Window(_) => ScriptTask::process_event(msg), + GlobalRef::Window(_) => ScriptThread::process_event(msg), GlobalRef::Worker(ref worker) => worker.process_event(msg), } } diff --git a/components/script/dom/bindings/js.rs b/components/script/dom/bindings/js.rs index dfe1acca376..5fb452883f3 100644 --- a/components/script/dom/bindings/js.rs +++ b/components/script/dom/bindings/js.rs @@ -33,7 +33,7 @@ use dom::node::Node; use js::jsapi::{Heap, JSObject, JSTracer}; use js::jsval::JSVal; use layout_interface::TrustedNodeAddress; -use script_task::STACK_ROOTS; +use script_thread::STACK_ROOTS; use std::cell::UnsafeCell; use std::default::Default; use std::hash::{Hash, Hasher}; @@ -41,7 +41,7 @@ use std::mem; use std::ops::Deref; use std::ptr; use util::mem::HeapSizeOf; -use util::task_state; +use util::thread_state; /// A traced reference to a DOM object /// @@ -66,7 +66,7 @@ impl HeapSizeOf for JS { impl JS { /// Returns `LayoutJS` containing the same pointer. pub unsafe fn to_layout(&self) -> LayoutJS { - debug_assert!(task_state::get().is_layout()); + debug_assert!(thread_state::get().is_layout()); LayoutJS { ptr: self.ptr.clone(), } @@ -78,7 +78,7 @@ impl JS { /// XXX Not a great API. Should be a call on Root instead #[allow(unrooted_must_root)] pub fn from_rooted(root: &Root) -> JS { - debug_assert!(task_state::get().is_script()); + debug_assert!(thread_state::get().is_script()); JS { ptr: unsafe { NonZero::new(&**root) }, } @@ -86,7 +86,7 @@ impl JS { /// Create a JS from a &T #[allow(unrooted_must_root)] pub fn from_ref(obj: &T) -> JS { - debug_assert!(task_state::get().is_script()); + debug_assert!(thread_state::get().is_script()); JS { ptr: unsafe { NonZero::new(&*obj) }, } @@ -97,7 +97,7 @@ impl Deref for JS { type Target = T; fn deref(&self) -> &T { - debug_assert!(task_state::get().is_script()); + debug_assert!(thread_state::get().is_script()); // We can only have &JS from a rooted thing, so it's safe to deref // it to &T. unsafe { &**self.ptr } @@ -123,7 +123,7 @@ impl LayoutJS { where U: Castable, T: DerivedFrom { - debug_assert!(task_state::get().is_layout()); + debug_assert!(thread_state::get().is_layout()); unsafe { mem::transmute_copy(self) } } @@ -131,7 +131,7 @@ impl LayoutJS { pub fn downcast(&self) -> Option> where U: DerivedFrom { - debug_assert!(task_state::get().is_layout()); + debug_assert!(thread_state::get().is_layout()); unsafe { if (*self.unsafe_get()).is::() { Some(mem::transmute_copy(self)) @@ -145,7 +145,7 @@ impl LayoutJS { impl LayoutJS { /// Get the reflector. pub unsafe fn get_jsobject(&self) -> *mut JSObject { - debug_assert!(task_state::get().is_layout()); + debug_assert!(thread_state::get().is_layout()); (**self.ptr).reflector().get_jsobject().get() } } @@ -184,7 +184,7 @@ impl Clone for JS { #[inline] #[allow(unrooted_must_root)] fn clone(&self) -> JS { - debug_assert!(task_state::get().is_script()); + debug_assert!(thread_state::get().is_script()); JS { ptr: self.ptr.clone(), } @@ -194,7 +194,7 @@ impl Clone for JS { impl Clone for LayoutJS { #[inline] fn clone(&self) -> LayoutJS { - debug_assert!(task_state::get().is_layout()); + debug_assert!(thread_state::get().is_layout()); LayoutJS { ptr: self.ptr.clone(), } @@ -205,7 +205,7 @@ impl LayoutJS { /// Create a new JS-owned value wrapped from an address known to be a /// `Node` pointer. pub unsafe fn from_trusted_node_address(inner: TrustedNodeAddress) -> LayoutJS { - debug_assert!(task_state::get().is_layout()); + debug_assert!(thread_state::get().is_layout()); let TrustedNodeAddress(addr) = inner; LayoutJS { ptr: NonZero::new(addr as *const Node), @@ -240,7 +240,7 @@ pub struct MutHeapJSVal { impl MutHeapJSVal { /// Create a new `MutHeapJSVal`. pub fn new() -> MutHeapJSVal { - debug_assert!(task_state::get().is_script()); + debug_assert!(thread_state::get().is_script()); MutHeapJSVal { val: UnsafeCell::new(Heap::default()), } @@ -249,7 +249,7 @@ impl MutHeapJSVal { /// Set this `MutHeapJSVal` to the given value, calling write barriers as /// appropriate. pub fn set(&self, val: JSVal) { - debug_assert!(task_state::get().is_script()); + debug_assert!(thread_state::get().is_script()); unsafe { let cell = self.val.get(); (*cell).set(val); @@ -258,7 +258,7 @@ impl MutHeapJSVal { /// Get the value in this `MutHeapJSVal`, calling read barriers as appropriate. pub fn get(&self) -> JSVal { - debug_assert!(task_state::get().is_script()); + debug_assert!(thread_state::get().is_script()); unsafe { (*self.val.get()).get() } } } @@ -278,7 +278,7 @@ pub struct MutHeap { impl MutHeap> { /// Create a new `MutHeap`. pub fn new(initial: &T) -> MutHeap> { - debug_assert!(task_state::get().is_script()); + debug_assert!(thread_state::get().is_script()); MutHeap { val: UnsafeCell::new(JS::from_ref(initial)), } @@ -286,7 +286,7 @@ impl MutHeap> { /// Set this `MutHeap` to the given value. pub fn set(&self, val: &T) { - debug_assert!(task_state::get().is_script()); + debug_assert!(thread_state::get().is_script()); unsafe { *self.val.get() = JS::from_ref(val); } @@ -294,7 +294,7 @@ impl MutHeap> { /// Get the value in this `MutHeap`. pub fn get(&self) -> Root { - debug_assert!(task_state::get().is_script()); + debug_assert!(thread_state::get().is_script()); unsafe { Root::from_ref(&*ptr::read(self.val.get())) } @@ -339,7 +339,7 @@ pub struct MutNullableHeap { impl MutNullableHeap> { /// Create a new `MutNullableHeap`. pub fn new(initial: Option<&T>) -> MutNullableHeap> { - debug_assert!(task_state::get().is_script()); + debug_assert!(thread_state::get().is_script()); MutNullableHeap { ptr: UnsafeCell::new(initial.map(JS::from_ref)), } @@ -350,7 +350,7 @@ impl MutNullableHeap> { pub fn or_init(&self, cb: F) -> Root where F: FnOnce() -> Root { - debug_assert!(task_state::get().is_script()); + debug_assert!(thread_state::get().is_script()); match self.get() { Some(inner) => inner, None => { @@ -365,14 +365,14 @@ impl MutNullableHeap> { /// For use by layout, which can't use safe types like Temporary. #[allow(unrooted_must_root)] pub unsafe fn get_inner_as_layout(&self) -> Option> { - debug_assert!(task_state::get().is_layout()); + debug_assert!(thread_state::get().is_layout()); ptr::read(self.ptr.get()).map(|js| js.to_layout()) } /// Get a rooted value out of this object #[allow(unrooted_must_root)] pub fn get(&self) -> Option> { - debug_assert!(task_state::get().is_script()); + debug_assert!(thread_state::get().is_script()); unsafe { ptr::read(self.ptr.get()).map(|o| Root::from_ref(&*o)) } @@ -380,7 +380,7 @@ impl MutNullableHeap> { /// Set this `MutNullableHeap` to the given value. pub fn set(&self, val: Option<&T>) { - debug_assert!(task_state::get().is_script()); + debug_assert!(thread_state::get().is_script()); unsafe { *self.ptr.get() = val.map(|p| JS::from_ref(p)); } @@ -407,7 +407,7 @@ impl<'a, T: Reflectable> PartialEq> for MutNullableHeap> { impl Default for MutNullableHeap { #[allow(unrooted_must_root)] fn default() -> MutNullableHeap { - debug_assert!(task_state::get().is_script()); + debug_assert!(thread_state::get().is_script()); MutNullableHeap { ptr: UnsafeCell::new(None), } @@ -426,7 +426,7 @@ impl LayoutJS { /// the only method that be safely accessed from layout. (The fact that /// this is unsafe is what necessitates the layout wrappers.) pub unsafe fn unsafe_get(&self) -> *const T { - debug_assert!(task_state::get().is_layout()); + debug_assert!(thread_state::get().is_layout()); *self.ptr } } @@ -479,7 +479,7 @@ impl Clone for RootCollectionPtr { impl RootCollection { /// Create an empty collection of roots pub fn new() -> RootCollection { - debug_assert!(task_state::get().is_script()); + debug_assert!(thread_state::get().is_script()); RootCollection { roots: UnsafeCell::new(vec![]), } @@ -487,7 +487,7 @@ impl RootCollection { /// Start tracking a stack-based root fn root(&self, untracked_reflector: *const Reflector) { - debug_assert!(task_state::get().is_script()); + debug_assert!(thread_state::get().is_script()); unsafe { let mut roots = &mut *self.roots.get(); roots.push(untracked_reflector); @@ -497,7 +497,7 @@ impl RootCollection { /// Stop tracking a stack-based root, asserting if the reflector isn't found fn unroot(&self, rooted: &Root) { - debug_assert!(task_state::get().is_script()); + debug_assert!(thread_state::get().is_script()); unsafe { let mut roots = &mut *self.roots.get(); let old_reflector = &*rooted.reflector(); @@ -562,7 +562,7 @@ impl Root { /// It cannot not outlive its associated `RootCollection`, and it gives /// out references which cannot outlive this new `Root`. pub fn new(unrooted: NonZero<*const T>) -> Root { - debug_assert!(task_state::get().is_script()); + debug_assert!(thread_state::get().is_script()); STACK_ROOTS.with(|ref collection| { let RootCollectionPtr(collection) = collection.get().unwrap(); unsafe { (*collection).root(&*(**unrooted).reflector()) } @@ -588,7 +588,7 @@ impl Root { impl Deref for Root { type Target = T; fn deref(&self) -> &T { - debug_assert!(task_state::get().is_script()); + debug_assert!(thread_state::get().is_script()); unsafe { &**self.ptr.deref() } } } diff --git a/components/script/dom/bindings/refcounted.rs b/components/script/dom/bindings/refcounted.rs index 4c884854c13..c7d67cba5fd 100644 --- a/components/script/dom/bindings/refcounted.rs +++ b/components/script/dom/bindings/refcounted.rs @@ -3,21 +3,21 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! A generic, safe mechanism by which DOM objects can be pinned and transferred -//! between tasks (or intra-task for asynchronous events). Akin to Gecko's +//! between threads (or intra-thread for asynchronous events). Akin to Gecko's //! nsMainThreadPtrHandle, this uses thread-safe reference counting and ensures -//! that the actual SpiderMonkey GC integration occurs on the script task via +//! that the actual SpiderMonkey GC integration occurs on the script thread via //! message passing. Ownership of a `Trusted` object means the DOM object of //! type T to which it points remains alive. Any other behaviour is undefined. //! To guarantee the lifetime of a DOM object when performing asynchronous operations, //! obtain a `Trusted` from that object and pass it along with each operation. -//! A usable pointer to the original DOM object can be obtained on the script task +//! A usable pointer to the original DOM object can be obtained on the script thread //! from a `Trusted` via the `to_temporary` method. //! //! The implementation of Trusted is as follows: -//! A hashtable resides in the script task, keyed on the pointer to the Rust DOM object. +//! A hashtable resides in the script thread, keyed on the pointer to the Rust DOM object. //! The values in this hashtable are atomic reference counts. When a Trusted object is //! created or cloned, this count is increased. When a Trusted is dropped, the count -//! decreases. If the count hits zero, a message is dispatched to the script task to remove +//! decreases. If the count hits zero, a message is dispatched to the script thread to remove //! the entry from the hashmap if the count is still zero. The JS reflector for the DOM object //! is rooted when a hashmap entry is first created, and unrooted when the hashmap entry //! is removed. @@ -28,7 +28,7 @@ use dom::bindings::reflector::{Reflectable, Reflector}; use dom::bindings::trace::trace_reflector; use js::jsapi::JSTracer; use libc; -use script_task::{CommonScriptMsg, ScriptChan}; +use script_thread::{CommonScriptMsg, ScriptChan}; use std::cell::RefCell; use std::collections::hash_map::Entry::{Occupied, Vacant}; use std::collections::hash_map::HashMap; @@ -52,13 +52,13 @@ pub struct TrustedReference(*const libc::c_void); unsafe impl Send for TrustedReference {} /// A safe wrapper around a raw pointer to a DOM object that can be -/// shared among tasks for use in asynchronous operations. The underlying +/// shared among threads for use in asynchronous operations. The underlying /// DOM object is guaranteed to live at least as long as the last outstanding /// `Trusted` instance. #[allow_unrooted_interior] pub struct Trusted { /// A pointer to the Rust DOM object of type T, but void to allow - /// sending `Trusted` between tasks, regardless of T's sendability. + /// sending `Trusted` between threads, regardless of T's sendability. ptr: *const libc::c_void, refcount: Arc>, script_chan: Box, @@ -125,7 +125,7 @@ impl Drop for Trusted { assert!(*refcount > 0); *refcount -= 1; if *refcount == 0 { - // It's possible this send will fail if the script task + // It's possible this send will fail if the script thread // has already exited. There's not much we can do at this // point though. let msg = CommonScriptMsg::RefcountCleanup(TrustedReference(self.ptr)); @@ -142,7 +142,7 @@ pub struct LiveDOMReferences { } impl LiveDOMReferences { - /// Set up the task-local data required for storing the outstanding DOM references. + /// Set up the thread-local data required for storing the outstanding DOM references. pub fn initialize() { LIVE_REFERENCES.with(|ref r| { *r.borrow_mut() = Some(LiveDOMReferences { diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index 496d70add18..aec55e62134 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -58,11 +58,11 @@ use msg::constellation_msg::ConstellationChan; use msg::constellation_msg::{PipelineId, SubpageId, WindowSizeData}; use net_traits::Metadata; use net_traits::image::base::Image; -use net_traits::image_cache_task::{ImageCacheChan, ImageCacheTask}; -use net_traits::storage_task::StorageType; +use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread}; +use net_traits::storage_thread::StorageType; use profile_traits::mem::ProfilerChan as MemProfilerChan; use profile_traits::time::ProfilerChan as TimeProfilerChan; -use script_task::ScriptChan; +use script_thread::ScriptChan; use script_traits::{LayoutMsg, ScriptMsg, TimerEventId, TimerSource, UntrustedNodeAddress}; use selectors::parser::PseudoElement; use selectors::states::*; @@ -262,7 +262,7 @@ no_jsmanaged_fields!(Receiver); no_jsmanaged_fields!(Rect); no_jsmanaged_fields!(Size2D); no_jsmanaged_fields!(Arc); -no_jsmanaged_fields!(Image, ImageCacheChan, ImageCacheTask); +no_jsmanaged_fields!(Image, ImageCacheChan, ImageCacheThread); no_jsmanaged_fields!(Metadata); no_jsmanaged_fields!(Atom, Namespace, QualName); no_jsmanaged_fields!(Trusted); diff --git a/components/script/dom/canvasrenderingcontext2d.rs b/components/script/dom/canvasrenderingcontext2d.rs index ef010055d6f..717494d80c6 100644 --- a/components/script/dom/canvasrenderingcontext2d.rs +++ b/components/script/dom/canvasrenderingcontext2d.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use canvas::canvas_paint_task::RectToi32; +use canvas::canvas_paint_thread::RectToi32; use canvas_traits::{Canvas2dMsg, CanvasCommonMsg, CanvasMsg}; use canvas_traits::{CompositionOrBlending, LineCapStyle, LineJoinStyle}; use canvas_traits::{FillOrStrokeStyle, FillRule, LinearGradientStyle, RadialGradientStyle, RepetitionStyle}; @@ -36,7 +36,7 @@ use euclid::rect::Rect; use euclid::size::Size2D; use ipc_channel::ipc::{self, IpcSender}; use net_traits::image::base::PixelFormat; -use net_traits::image_cache_task::ImageResponse; +use net_traits::image_cache_thread::ImageResponse; use num::{Float, ToPrimitive}; use script_traits::ScriptMsg as ConstellationMsg; use std::cell::Cell; @@ -124,7 +124,7 @@ impl CanvasRenderingContext2D { -> CanvasRenderingContext2D { let (sender, receiver) = ipc::channel().unwrap(); let constellation_chan = global.constellation_chan(); - constellation_chan.0.send(ConstellationMsg::CreateCanvasPaintTask(size, sender)).unwrap(); + constellation_chan.0.send(ConstellationMsg::CreateCanvasPaintThread(size, sender)).unwrap(); let (ipc_renderer, renderer_id) = receiver.recv().unwrap(); CanvasRenderingContext2D { reflector_: Reflector::new(), diff --git a/components/script/dom/closeevent.rs b/components/script/dom/closeevent.rs index ca1186227e7..44635462ad2 100644 --- a/components/script/dom/closeevent.rs +++ b/components/script/dom/closeevent.rs @@ -11,7 +11,7 @@ use dom::bindings::inheritance::Castable; use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; use dom::event::{Event, EventBubbles, EventCancelable}; -use script_task::ScriptChan; +use script_thread::ScriptChan; use string_cache::Atom; use util::str::DOMString; diff --git a/components/script/dom/dedicatedworkerglobalscope.rs b/components/script/dom/dedicatedworkerglobalscope.rs index 07bef0cd348..c63b657cd19 100644 --- a/components/script/dom/dedicatedworkerglobalscope.rs +++ b/components/script/dom/dedicatedworkerglobalscope.rs @@ -28,17 +28,17 @@ use js::rust::Runtime; use msg::constellation_msg::PipelineId; use net_traits::{LoadContext, load_whole_resource}; use rand::random; -use script_task::ScriptTaskEventCategory::WorkerEvent; -use script_task::{ScriptTask, ScriptChan, ScriptPort, StackRootTLS, CommonScriptMsg}; +use script_thread::ScriptThreadEventCategory::WorkerEvent; +use script_thread::{ScriptThread, ScriptChan, ScriptPort, StackRootTLS, CommonScriptMsg}; use script_traits::{TimerEvent, TimerSource}; use std::mem::replace; use std::rc::Rc; use std::sync::mpsc::{Receiver, RecvError, Select, Sender, channel}; use url::Url; use util::str::DOMString; -use util::task::spawn_named; -use util::task_state; -use util::task_state::{IN_WORKER, SCRIPT}; +use util::thread::spawn_named; +use util::thread_state; +use util::thread_state::{IN_WORKER, SCRIPT}; /// Messages used to control the worker event loops pub enum WorkerScriptMsg { @@ -215,12 +215,15 @@ impl DedicatedWorkerGlobalScope { receiver: Receiver<(TrustedWorkerAddress, WorkerScriptMsg)>) { let serialized_worker_url = worker_url.serialize(); spawn_named(format!("WebWorker for {}", serialized_worker_url), move || { - task_state::initialize(SCRIPT | IN_WORKER); + thread_state::initialize(SCRIPT | IN_WORKER); let roots = RootCollection::new(); let _stack_roots_tls = StackRootTLS::new(&roots); - let (url, source) = match load_whole_resource(LoadContext::Script, &init.resource_task, worker_url, None) { + let (url, source) = match load_whole_resource(LoadContext::Script, + &init.resource_thread, + worker_url, + None) { Err(_) => { println!("error loading script {}", serialized_worker_url); parent_sender.send(CommonScriptMsg::RunnableMsg(WorkerEvent, @@ -232,7 +235,7 @@ impl DedicatedWorkerGlobalScope { } }; - let runtime = Rc::new(ScriptTask::new_rt_and_cx()); + let runtime = Rc::new(ScriptThread::new_rt_and_cx()); let (devtools_mpsc_chan, devtools_mpsc_port) = channel(); ROUTER.route_ipc_receiver_to_mpsc_sender(from_devtools_receiver, devtools_mpsc_chan); @@ -343,7 +346,7 @@ impl DedicatedWorkerGlobalScope { let scope = self.upcast::(); let cx = scope.get_cx(); let path_seg = format!("url({})", scope.get_url()); - let reports = ScriptTask::get_reports(cx, path_seg); + let reports = ScriptThread::get_reports(cx, path_seg); reports_chan.send(reports); }, } diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index b3d747fc4d9..c4edaa7736c 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -88,8 +88,8 @@ use net_traits::ControlMsg::{GetCookiesForUrl, SetCookiesForUrl}; use net_traits::CookieSource::NonHTTP; use net_traits::{AsyncResponseTarget, PendingAsyncLoad}; use num::ToPrimitive; -use script_task::CSSError; -use script_task::{MainThreadScriptMsg, Runnable}; +use script_thread::CSSError; +use script_thread::{MainThreadScriptMsg, Runnable}; use script_traits::{ScriptMsg as ConstellationMsg, ScriptToCompositorMsg}; use script_traits::{TouchEventType, TouchId, UntrustedNodeAddress}; use std::ascii::AsciiExt; @@ -2318,7 +2318,7 @@ impl DocumentMethods for Document { return Err(Error::Security); } let (tx, rx) = ipc::channel().unwrap(); - let _ = self.window.resource_task().send(GetCookiesForUrl((*url).clone(), tx, NonHTTP)); + let _ = self.window.resource_thread().send(GetCookiesForUrl((*url).clone(), tx, NonHTTP)); let cookies = rx.recv().unwrap(); Ok(cookies.map_or(DOMString::new(), DOMString::from)) } @@ -2331,7 +2331,7 @@ impl DocumentMethods for Document { return Err(Error::Security); } let _ = self.window - .resource_task() + .resource_thread() .send(SetCookiesForUrl((*url).clone(), String::from(cookie), NonHTTP)); Ok(()) } diff --git a/components/script/dom/filereader.rs b/components/script/dom/filereader.rs index 640cdca19a5..67925cb92a7 100644 --- a/components/script/dom/filereader.rs +++ b/components/script/dom/filereader.rs @@ -22,12 +22,12 @@ use encoding::label::encoding_from_whatwg_label; use encoding::types::{DecoderTrap, EncodingRef}; use hyper::mime::{Attr, Mime}; use rustc_serialize::base64::{CharacterSet, Config, Newline, ToBase64}; -use script_task::ScriptTaskEventCategory::FileRead; -use script_task::{CommonScriptMsg, Runnable, ScriptChan}; +use script_thread::ScriptThreadEventCategory::FileRead; +use script_thread::{CommonScriptMsg, Runnable, ScriptChan}; use std::cell::Cell; use string_cache::Atom; use util::str::DOMString; -use util::task::spawn_named; +use util::thread::spawn_named; #[derive(PartialEq, Clone, Copy, JSTraceable, HeapSizeOf)] pub enum FileReaderFunction { @@ -360,10 +360,10 @@ impl FileReader { let load_data = ReadMetaData::new(String::from(type_), label.map(String::from), function); - let fr = Trusted::new(self, global.file_reading_task_source()); + let fr = Trusted::new(self, global.file_reading_thread_source()); let gen_id = self.generation_id.get(); - let script_chan = global.file_reading_task_source(); + let script_chan = global.file_reading_thread_source(); spawn_named("file reader async operation".to_owned(), move || { perform_annotated_read_operation(gen_id, load_data, blob_contents, fr, script_chan) @@ -404,17 +404,17 @@ impl Runnable for FileReaderEvent { } } -// https://w3c.github.io/FileAPI/#task-read-operation +// https://w3c.github.io/FileAPI/#thread-read-operation fn perform_annotated_read_operation(gen_id: GenerationId, data: ReadMetaData, blob_contents: DataSlice, filereader: TrustedFileReader, script_chan: Box) { let chan = &script_chan; // Step 4 - let task = box FileReaderEvent::ProcessRead(filereader.clone(), gen_id); - chan.send(CommonScriptMsg::RunnableMsg(FileRead, task)).unwrap(); + let thread = box FileReaderEvent::ProcessRead(filereader.clone(), gen_id); + chan.send(CommonScriptMsg::RunnableMsg(FileRead, thread)).unwrap(); - let task = box FileReaderEvent::ProcessReadData(filereader.clone(), gen_id); - chan.send(CommonScriptMsg::RunnableMsg(FileRead, task)).unwrap(); + let thread = box FileReaderEvent::ProcessReadData(filereader.clone(), gen_id); + chan.send(CommonScriptMsg::RunnableMsg(FileRead, thread)).unwrap(); - let task = box FileReaderEvent::ProcessReadEOF(filereader, gen_id, data, blob_contents); - chan.send(CommonScriptMsg::RunnableMsg(FileRead, task)).unwrap(); + let thread = box FileReaderEvent::ProcessReadEOF(filereader, gen_id, data, blob_contents); + chan.send(CommonScriptMsg::RunnableMsg(FileRead, thread)).unwrap(); } diff --git a/components/script/dom/htmlcanvaselement.rs b/components/script/dom/htmlcanvaselement.rs index b0659eb003f..e136638338d 100644 --- a/components/script/dom/htmlcanvaselement.rs +++ b/components/script/dom/htmlcanvaselement.rs @@ -332,11 +332,11 @@ impl<'a> From<&'a WebGLContextAttributes> for GLContextAttributes { pub mod utils { use dom::window::Window; use ipc_channel::ipc; - use net_traits::image_cache_task::{ImageCacheChan, ImageResponse}; + use net_traits::image_cache_thread::{ImageCacheChan, ImageResponse}; use url::Url; pub fn request_image_from_cache(window: &Window, url: Url) -> ImageResponse { - let image_cache = window.image_cache_task(); + let image_cache = window.image_cache_thread(); let (response_chan, response_port) = ipc::channel().unwrap(); image_cache.request_image(url, ImageCacheChan(response_chan), None); let result = response_port.recv().unwrap(); diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index e957cda4199..512a0d6a56c 100644 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -32,7 +32,7 @@ use hyper::header::ContentType; use hyper::method::Method; use hyper::mime; use msg::constellation_msg::LoadData; -use script_task::{MainThreadScriptMsg, ScriptChan}; +use script_thread::{MainThreadScriptMsg, ScriptChan}; use std::borrow::ToOwned; use std::cell::Cell; use string_cache::Atom; diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs index 39b485d6d6c..6474d360a75 100644 --- a/components/script/dom/htmlimageelement.rs +++ b/components/script/dom/htmlimageelement.rs @@ -22,9 +22,9 @@ use dom::virtualmethods::VirtualMethods; use ipc_channel::ipc; use ipc_channel::router::ROUTER; use net_traits::image::base::Image; -use net_traits::image_cache_task::{ImageResponder, ImageResponse}; -use script_task::ScriptTaskEventCategory::UpdateReplacedElement; -use script_task::{CommonScriptMsg, Runnable, ScriptChan}; +use net_traits::image_cache_thread::{ImageResponder, ImageResponse}; +use script_thread::ScriptThreadEventCategory::UpdateReplacedElement; +use script_thread::{CommonScriptMsg, Runnable, ScriptChan}; use std::sync::Arc; use string_cache::Atom; use url::Url; @@ -89,7 +89,7 @@ impl HTMLImageElement { fn update_image(&self, value: Option<(DOMString, Url)>) { let document = document_from_node(self); let window = document.window(); - let image_cache = window.image_cache_task(); + let image_cache = window.image_cache_thread(); match value { None => { *self.url.borrow_mut() = None; @@ -101,12 +101,12 @@ impl HTMLImageElement { let img_url = img_url.unwrap(); *self.url.borrow_mut() = Some(img_url.clone()); - let trusted_node = Trusted::new(self, window.networking_task_source()); + let trusted_node = Trusted::new(self, window.networking_thread_source()); let (responder_sender, responder_receiver) = ipc::channel().unwrap(); - let script_chan = window.networking_task_source(); + let script_chan = window.networking_thread_source(); let wrapper = window.get_runnable_wrapper(); ROUTER.add_route(responder_receiver.to_opaque(), box move |message| { - // Return the image via a message to the script task, which marks the element + // Return the image via a message to the script thread, which marks the element // as dirty and triggers a reflow. let image_response = message.to().unwrap(); let runnable = ImageResponseHandlerRunnable::new( diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index 58d42c57201..2738c897e6b 100644 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -29,8 +29,8 @@ use dom::node::{document_from_node, window_from_node}; use dom::nodelist::NodeList; use dom::virtualmethods::VirtualMethods; use msg::constellation_msg::ConstellationChan; -use script_task::ScriptTaskEventCategory::InputEvent; -use script_task::{CommonScriptMsg, Runnable}; +use script_thread::ScriptThreadEventCategory::InputEvent; +use script_thread::{CommonScriptMsg, Runnable}; use script_traits::ScriptMsg as ConstellationMsg; use selectors::states::*; use std::borrow::ToOwned; @@ -937,7 +937,7 @@ impl ChangeEventRunnable { pub fn send(node: &Node) { let window = window_from_node(node); let window = window.r(); - let chan = window.user_interaction_task_source(); + let chan = window.user_interaction_thread_source(); let handler = Trusted::new(node, chan.clone()); let dispatcher = ChangeEventRunnable { element: handler, diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs index b3005be343d..58ce5dc6ea0 100644 --- a/components/script/dom/htmllinkelement.rs +++ b/components/script/dom/htmllinkelement.rs @@ -197,7 +197,7 @@ impl HTMLLinkElement { // TODO: #8085 - Don't load external stylesheets if the node's mq doesn't match. let doc = window.Document(); - let script_chan = window.networking_task_source(); + let script_chan = window.networking_thread_source(); let elem = Trusted::new(self, script_chan.clone()); let context = Arc::new(Mutex::new(StylesheetContext { diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs index 5db616ddf2b..ee4243874df 100644 --- a/components/script/dom/htmlscriptelement.rs +++ b/components/script/dom/htmlscriptelement.rs @@ -34,8 +34,8 @@ use js::jsapi::RootedValue; use js::jsval::UndefinedValue; use net_traits::{AsyncResponseListener, AsyncResponseTarget, Metadata}; use network_listener::{NetworkListener, PreInvoke}; -use script_task::ScriptTaskEventCategory::ScriptEvent; -use script_task::{CommonScriptMsg, Runnable, ScriptChan}; +use script_thread::ScriptThreadEventCategory::ScriptEvent; +use script_thread::{CommonScriptMsg, Runnable, ScriptChan}; use std::ascii::AsciiExt; use std::cell::Cell; use std::mem; @@ -272,7 +272,7 @@ impl HTMLScriptElement { Ok(url) => { // Step 14.5-7. // TODO(#9186): use the fetch infrastructure. - let script_chan = window.networking_task_source(); + let script_chan = window.networking_thread_source(); let elem = Trusted::new(self, script_chan.clone()); let context = Arc::new(Mutex::new(ScriptContext { @@ -432,7 +432,7 @@ impl HTMLScriptElement { if external { self.dispatch_load_event(); } else { - let chan = window.dom_manipulation_task_source(); + let chan = window.dom_manipulation_thread_source(); let handler = Trusted::new(self, chan.clone()); let dispatcher = box EventDispatcher { element: handler, @@ -445,7 +445,7 @@ impl HTMLScriptElement { pub fn queue_error_event(&self) { let window = window_from_node(self); let window = window.r(); - let chan = window.dom_manipulation_task_source(); + let chan = window.dom_manipulation_thread_source(); let handler = Trusted::new(self, chan.clone()); let dispatcher = box EventDispatcher { element: handler, diff --git a/components/script/dom/mod.rs b/components/script/dom/mod.rs index 4fc7d110745..89b0745dbc3 100644 --- a/components/script/dom/mod.rs +++ b/components/script/dom/mod.rs @@ -35,7 +35,7 @@ //! [`MutNullableJS`](bindings/js/struct.MutNullableJS.html) and //! [`MutHeap`](bindings/js/struct.MutHeap.html) smart pointers and //! [the tracing implementation](bindings/trace/index.html); -//! * rooting pointers from across task boundaries or in channels: the +//! * rooting pointers from across thread boundaries or in channels: the //! [`Trusted`](bindings/refcounted/struct.Trusted.html) smart pointer; //! * extracting pointers to DOM objects from their reflectors: the //! [`Unrooted`](bindings/js/struct.Unrooted.html) smart pointer. @@ -196,7 +196,7 @@ //! Layout code can access the DOM through the //! [`LayoutJS`](bindings/js/struct.LayoutJS.html) smart pointer. This does not //! keep the DOM object alive; we ensure that no DOM code (Garbage Collection -//! in particular) runs while the layout task is accessing the DOM. +//! in particular) runs while the layout thread is accessing the DOM. //! //! Methods accessible to layout are implemented on `LayoutJS` using //! `LayoutFooHelpers` traits. diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 76b858cf92d..e5d1367e993 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -64,7 +64,7 @@ use std::iter::{self, FilterMap, Peekable}; use std::mem; use string_cache::{Atom, Namespace, QualName}; use util::str::DOMString; -use util::task_state; +use util::thread_state; use uuid::Uuid; // @@ -113,9 +113,9 @@ pub struct Node { /// are this node. ranges: WeakRangeVec, - /// Style+Layout information. Only the layout task may touch this data. + /// Style+Layout information. Only the layout thread may touch this data. /// - /// Must be sent back to the layout task to be destroyed when this + /// Must be sent back to the layout thread to be destroyed when this /// node is finalized. style_and_layout_data: Cell>, @@ -183,9 +183,9 @@ no_jsmanaged_fields!(OpaqueStyleAndLayoutData); impl OpaqueStyleAndLayoutData { - /// Sends the style and layout data, if any, back to the layout task to be destroyed. + /// Sends the style and layout data, if any, back to the layout thread to be destroyed. pub fn dispose(self, node: &Node) { - debug_assert!(task_state::get().is_script()); + debug_assert!(thread_state::get().is_script()); let win = window_from_node(node); let LayoutChan(chan) = win.layout_chan(); node.style_and_layout_data.set(None); diff --git a/components/script/dom/servohtmlparser.rs b/components/script/dom/servohtmlparser.rs index 26588986016..0a541fbea44 100644 --- a/components/script/dom/servohtmlparser.rs +++ b/components/script/dom/servohtmlparser.rs @@ -29,7 +29,7 @@ use msg::constellation_msg::{PipelineId, SubpageId}; use net_traits::{AsyncResponseListener, Metadata}; use network_listener::PreInvoke; use parse::Parser; -use script_task::{ScriptChan, ScriptTask}; +use script_thread::{ScriptChan, ScriptThread}; use std::cell::Cell; use std::cell::UnsafeCell; use std::default::Default; @@ -241,7 +241,7 @@ impl AsyncResponseListener for ParserContext { fn headers_available(&mut self, metadata: Metadata) { let content_type = metadata.content_type.clone(); - let parser = ScriptTask::page_fetch_complete(self.id.clone(), self.subpage.clone(), + let parser = ScriptThread::page_fetch_complete(self.id.clone(), self.subpage.clone(), metadata); let parser = match parser { Some(parser) => parser, @@ -366,7 +366,7 @@ impl<'a> Parser for &'a ServoHTMLParser { self.document.set_current_parser(None); if let Some(pipeline) = self.pipeline { - ScriptTask::parsing_complete(pipeline); + ScriptThread::parsing_complete(pipeline); } } } diff --git a/components/script/dom/servoxmlparser.rs b/components/script/dom/servoxmlparser.rs index 1433e9f49e1..6baa7e183ff 100644 --- a/components/script/dom/servoxmlparser.rs +++ b/components/script/dom/servoxmlparser.rs @@ -15,7 +15,7 @@ use dom::window::Window; use js::jsapi::JSTracer; use msg::constellation_msg::PipelineId; use parse::Parser; -use script_task::ScriptTask; +use script_thread::ScriptThread; use std::cell::Cell; use url::Url; use xml5ever::tokenizer; @@ -68,7 +68,7 @@ impl<'a> Parser for &'a ServoXMLParser { self.document.set_current_parser(None); if let Some(pipeline) = self.pipeline { - ScriptTask::parsing_complete(pipeline); + ScriptThread::parsing_complete(pipeline); } } } diff --git a/components/script/dom/storage.rs b/components/script/dom/storage.rs index e29c5093f6c..3e2d54e6456 100644 --- a/components/script/dom/storage.rs +++ b/components/script/dom/storage.rs @@ -14,9 +14,9 @@ use dom::event::{Event, EventBubbles, EventCancelable}; use dom::storageevent::StorageEvent; use dom::urlhelper::UrlHelper; use ipc_channel::ipc; -use net_traits::storage_task::{StorageTask, StorageTaskMsg, StorageType}; +use net_traits::storage_thread::{StorageThread, StorageThreadMsg, StorageType}; use page::IterablePage; -use script_task::{MainThreadRunnable, MainThreadScriptMsg, ScriptTask}; +use script_thread::{MainThreadRunnable, MainThreadScriptMsg, ScriptThread}; use std::sync::mpsc::channel; use url::Url; use util::str::DOMString; @@ -47,10 +47,10 @@ impl Storage { global_ref.get_url() } - fn get_storage_task(&self) -> StorageTask { + fn get_storage_thread(&self) -> StorageThread { let global_root = self.global.root(); let global_ref = global_root.r(); - global_ref.as_window().storage_task() + global_ref.as_window().storage_thread() } } @@ -60,7 +60,7 @@ impl StorageMethods for Storage { fn Length(&self) -> u32 { let (sender, receiver) = ipc::channel().unwrap(); - self.get_storage_task().send(StorageTaskMsg::Length(sender, self.get_url(), self.storage_type)).unwrap(); + self.get_storage_thread().send(StorageThreadMsg::Length(sender, self.get_url(), self.storage_type)).unwrap(); receiver.recv().unwrap() as u32 } @@ -68,7 +68,9 @@ impl StorageMethods for Storage { fn Key(&self, index: u32) -> Option { let (sender, receiver) = ipc::channel().unwrap(); - self.get_storage_task().send(StorageTaskMsg::Key(sender, self.get_url(), self.storage_type, index)).unwrap(); + self.get_storage_thread() + .send(StorageThreadMsg::Key(sender, self.get_url(), self.storage_type, index)) + .unwrap(); receiver.recv().unwrap().map(DOMString::from) } @@ -77,8 +79,8 @@ impl StorageMethods for Storage { let (sender, receiver) = ipc::channel().unwrap(); let name = String::from(name); - let msg = StorageTaskMsg::GetItem(sender, self.get_url(), self.storage_type, name); - self.get_storage_task().send(msg).unwrap(); + let msg = StorageThreadMsg::GetItem(sender, self.get_url(), self.storage_type, name); + self.get_storage_thread().send(msg).unwrap(); receiver.recv().unwrap().map(DOMString::from) } @@ -88,8 +90,8 @@ impl StorageMethods for Storage { let name = String::from(name); let value = String::from(value); - let msg = StorageTaskMsg::SetItem(sender, self.get_url(), self.storage_type, name.clone(), value.clone()); - self.get_storage_task().send(msg).unwrap(); + let msg = StorageThreadMsg::SetItem(sender, self.get_url(), self.storage_type, name.clone(), value.clone()); + self.get_storage_thread().send(msg).unwrap(); match receiver.recv().unwrap() { Err(_) => Err(Error::QuotaExceeded), Ok((changed, old_value)) => { @@ -106,8 +108,8 @@ impl StorageMethods for Storage { let (sender, receiver) = ipc::channel().unwrap(); let name = String::from(name); - let msg = StorageTaskMsg::RemoveItem(sender, self.get_url(), self.storage_type, name.clone()); - self.get_storage_task().send(msg).unwrap(); + let msg = StorageThreadMsg::RemoveItem(sender, self.get_url(), self.storage_type, name.clone()); + self.get_storage_thread().send(msg).unwrap(); if let Some(old_value) = receiver.recv().unwrap() { self.broadcast_change_notification(Some(name), Some(old_value), None); } @@ -117,7 +119,7 @@ impl StorageMethods for Storage { fn Clear(&self) { let (sender, receiver) = ipc::channel().unwrap(); - self.get_storage_task().send(StorageTaskMsg::Clear(sender, self.get_url(), self.storage_type)).unwrap(); + self.get_storage_thread().send(StorageThreadMsg::Clear(sender, self.get_url(), self.storage_type)).unwrap(); if receiver.recv().unwrap() { self.broadcast_change_notification(None, None, None); } @@ -127,7 +129,7 @@ impl StorageMethods for Storage { fn SupportedPropertyNames(&self) -> Vec { let (sender, receiver) = ipc::channel().unwrap(); - self.get_storage_task().send(StorageTaskMsg::Keys(sender, self.get_url(), self.storage_type)).unwrap(); + self.get_storage_thread().send(StorageThreadMsg::Keys(sender, self.get_url(), self.storage_type)).unwrap(); receiver.recv().unwrap().iter().cloned().map(DOMString::from).collect() // FIXME: inefficient? } @@ -155,7 +157,7 @@ impl Storage { let global_root = self.global.root(); let global_ref = global_root.r(); let main_script_chan = global_ref.as_window().main_thread_script_chan(); - let script_chan = global_ref.dom_manipulation_task_source(); + let script_chan = global_ref.dom_manipulation_thread_source(); let trusted_storage = Trusted::new(self, script_chan); main_script_chan.send(MainThreadScriptMsg::MainThreadRunnableMsg( box StorageEventRunnable::new(trusted_storage, key, old_value, new_value))).unwrap(); @@ -177,7 +179,7 @@ impl StorageEventRunnable { } impl MainThreadRunnable for StorageEventRunnable { - fn handler(self: Box, script_task: &ScriptTask) { + fn handler(self: Box, script_thread: &ScriptThread) { let this = *self; let storage_root = this.element.root(); let storage = storage_root.r(); @@ -195,7 +197,7 @@ impl MainThreadRunnable for StorageEventRunnable { Some(storage) ); - let root_page = script_task.root_page(); + let root_page = script_thread.root_page(); for it_page in root_page.iter() { let it_window_root = it_page.window(); let it_window = it_window_root.r(); diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index 6b6c310bcf0..91c5e613f35 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -31,7 +31,7 @@ use ipc_channel::ipc::{self, IpcSender}; use js::jsapi::{JSContext, JSObject, RootedValue}; use js::jsval::{BooleanValue, DoubleValue, Int32Value, JSVal, NullValue, UndefinedValue}; use net_traits::image::base::PixelFormat; -use net_traits::image_cache_task::ImageResponse; +use net_traits::image_cache_thread::ImageResponse; use offscreen_gl_context::GLContextAttributes; use script_traits::ScriptMsg as ConstellationMsg; use std::cell::Cell; @@ -91,7 +91,7 @@ impl WebGLRenderingContext { let (sender, receiver) = ipc::channel().unwrap(); let constellation_chan = global.constellation_chan(); constellation_chan.0 - .send(ConstellationMsg::CreateWebGLPaintTask(size, attrs, sender)) + .send(ConstellationMsg::CreateWebGLPaintThread(size, attrs, sender)) .unwrap(); let result = receiver.recv().unwrap(); @@ -614,7 +614,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { } // TODO(ecoal95): Probably in the future we should keep track of the - // generated objects, either here or in the webgl task + // generated objects, either here or in the webgl thread // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5 fn CreateBuffer(&self) -> Option> { WebGLBuffer::maybe_new(self.global.root().r(), self.ipc_renderer.clone()) diff --git a/components/script/dom/webglshader.rs b/components/script/dom/webglshader.rs index 8046fd5f5ed..9fd35610a37 100644 --- a/components/script/dom/webglshader.rs +++ b/components/script/dom/webglshader.rs @@ -100,9 +100,9 @@ impl WebGLShader { &BuiltInResources::default()).unwrap(); match validator.compile_and_translate(&[source.as_bytes()]) { Ok(translated_source) => { - // NOTE: At this point we should be pretty sure that the compilation in the paint task + // NOTE: At this point we should be pretty sure that the compilation in the paint thread // will succeed. - // It could be interesting to retrieve the info log from the paint task though + // It could be interesting to retrieve the info log from the paint thread though let msg = CanvasWebGLMsg::CompileShader(self.id, translated_source); self.renderer.send(CanvasMsg::WebGL(msg)).unwrap(); self.compilation_status.set(ShaderCompilationStatus::Succeeded); diff --git a/components/script/dom/websocket.rs b/components/script/dom/websocket.rs index 579c9466c2f..95ade2e61d7 100644 --- a/components/script/dom/websocket.rs +++ b/components/script/dom/websocket.rs @@ -32,8 +32,8 @@ use net_traits::hosts::replace_hosts; use net_traits::unwrap_websocket_protocol; use net_traits::{WebSocketCommunicate, WebSocketConnectData, WebSocketDomAction, WebSocketNetworkEvent}; use ref_slice::ref_slice; -use script_task::ScriptTaskEventCategory::WebSocketEvent; -use script_task::{CommonScriptMsg, Runnable}; +use script_thread::ScriptThreadEventCategory::WebSocketEvent; +use script_thread::{CommonScriptMsg, Runnable}; use std::borrow::ToOwned; use std::cell::Cell; use std::ptr; @@ -139,7 +139,7 @@ pub struct WebSocket { global: GlobalField, ready_state: Cell, buffered_amount: Cell, - clearing_buffer: Cell, //Flag to tell if there is a running task to clear buffered_amount + clearing_buffer: Cell, //Flag to tell if there is a running thread to clear buffered_amount #[ignore_heap_size_of = "Defined in std"] sender: DOMRefCell>>, failed: Cell, //Flag to tell if websocket was closed due to failure @@ -183,7 +183,7 @@ impl WebSocket { -> Fallible> { // Step 1. let resource_url = try!(Url::parse(&url).map_err(|_| Error::Syntax)); - // Although we do this replace and parse operation again in the resource task, + // Although we do this replace and parse operation again in the resource thread, // we try here to be able to immediately throw a syntax error on failure. let _ = try!(parse_url(&replace_hosts(&resource_url)).map_err(|_| Error::Syntax)); // Step 2: Disallow https -> ws connections. @@ -223,7 +223,7 @@ impl WebSocket { // Step 7. let ws = WebSocket::new(global, resource_url.clone()); - let address = Trusted::new(ws.r(), global.networking_task_source()); + let address = Trusted::new(ws.r(), global.networking_thread_source()); let origin = global.get_url().serialize(); let protocols: Vec = protocols.iter().map(|x| String::from(x.clone())).collect(); @@ -234,7 +234,7 @@ impl WebSocket { protocols: protocols, }; - // Create the interface for communication with the resource task + // Create the interface for communication with the resource thread let (dom_action_sender, resource_action_receiver): (IpcSender, IpcReceiver) = ipc::channel().unwrap(); @@ -247,36 +247,36 @@ impl WebSocket { action_receiver: resource_action_receiver, }; - let resource_task = global.resource_task(); - let _ = resource_task.send(WebsocketConnect(connect, connect_data)); + let resource_thread = global.resource_thread(); + let _ = resource_thread.send(WebsocketConnect(connect, connect_data)); *ws.sender.borrow_mut() = Some(dom_action_sender); let moved_address = address.clone(); - let sender = global.networking_task_source(); + let sender = global.networking_thread_source(); thread::spawn(move || { while let Ok(event) = dom_event_receiver.recv() { match event { WebSocketNetworkEvent::ConnectionEstablished(headers, protocols) => { - let open_task = box ConnectionEstablishedTask { + let open_thread = box ConnectionEstablishedTask { addr: moved_address.clone(), headers: headers, protocols: protocols, }; - sender.send(CommonScriptMsg::RunnableMsg(WebSocketEvent, open_task)).unwrap(); + sender.send(CommonScriptMsg::RunnableMsg(WebSocketEvent, open_thread)).unwrap(); }, WebSocketNetworkEvent::MessageReceived(message) => { - let message_task = box MessageReceivedTask { + let message_thread = box MessageReceivedTask { address: moved_address.clone(), message: message, }; - sender.send(CommonScriptMsg::RunnableMsg(WebSocketEvent, message_task)).unwrap(); + sender.send(CommonScriptMsg::RunnableMsg(WebSocketEvent, message_thread)).unwrap(); }, WebSocketNetworkEvent::Close => { - let task = box CloseTask { + let thread = box CloseTask { addr: moved_address.clone(), }; - sender.send(CommonScriptMsg::RunnableMsg(WebSocketEvent, task)).unwrap(); + sender.send(CommonScriptMsg::RunnableMsg(WebSocketEvent, thread)).unwrap(); }, } } @@ -296,7 +296,7 @@ impl WebSocket { }; let global = self.global.root(); - let chan = global.r().networking_task_source(); + let chan = global.r().networking_thread_source(); let address = Trusted::new(self, chan.clone()); match data_byte_len.checked_add(self.buffered_amount.get()) { @@ -469,11 +469,11 @@ impl Runnable for ConnectionEstablishedTask { if !self.protocols.is_empty() && self.headers.get::().is_none() { ws.failed.set(true); ws.ready_state.set(WebSocketRequestState::Closing); - let task = box CloseTask { + let thread = box CloseTask { addr: self.addr, }; - let sender = global.r().networking_task_source(); - sender.send(CommonScriptMsg::RunnableMsg(WebSocketEvent, task)).unwrap(); + let sender = global.r().networking_thread_source(); + sender.send(CommonScriptMsg::RunnableMsg(WebSocketEvent, thread)).unwrap(); return; } diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index c47b9164a43..8406583ed63 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -47,17 +47,17 @@ use msg::ParseErrorReporter; use msg::constellation_msg::{ConstellationChan, DocumentState, LoadData}; use msg::constellation_msg::{MozBrowserEvent, PipelineId, SubpageId, WindowSizeData}; use msg::webdriver_msg::{WebDriverJSError, WebDriverJSResult}; -use net_traits::ResourceTask; -use net_traits::image_cache_task::{ImageCacheChan, ImageCacheTask}; -use net_traits::storage_task::{StorageTask, StorageType}; +use net_traits::ResourceThread; +use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread}; +use net_traits::storage_thread::{StorageThread, StorageType}; use num::traits::ToPrimitive; use page::Page; use profile_traits::mem; use reporter::CSSErrorReporter; use rustc_serialize::base64::{FromBase64, STANDARD, ToBase64}; -use script_task::{DOMManipulationTaskSource, UserInteractionTaskSource, NetworkingTaskSource}; -use script_task::{HistoryTraversalTaskSource, FileReadingTaskSource, SendableMainThreadScriptChan}; -use script_task::{ScriptChan, ScriptPort, MainThreadScriptChan, MainThreadScriptMsg, RunnableWrapper}; +use script_thread::{DOMManipulationThreadSource, UserInteractionThreadSource, NetworkingThreadSource}; +use script_thread::{HistoryTraversalThreadSource, FileReadingThreadSource, SendableMainThreadScriptChan}; +use script_thread::{ScriptChan, ScriptPort, MainThreadScriptChan, MainThreadScriptMsg, RunnableWrapper}; use script_traits::ScriptMsg as ConstellationMsg; use script_traits::{MsDuration, ScriptToCompositorMsg, TimerEvent, TimerEventId, TimerEventRequest, TimerSource}; use selectors::parser::PseudoElement; @@ -116,21 +116,21 @@ pub struct Window { eventtarget: EventTarget, #[ignore_heap_size_of = "trait objects are hard"] script_chan: MainThreadScriptChan, - #[ignore_heap_size_of = "task sources are hard"] - dom_manipulation_task_source: DOMManipulationTaskSource, - #[ignore_heap_size_of = "task sources are hard"] - user_interaction_task_source: UserInteractionTaskSource, - #[ignore_heap_size_of = "task sources are hard"] - networking_task_source: NetworkingTaskSource, - #[ignore_heap_size_of = "task sources are hard"] - history_traversal_task_source: HistoryTraversalTaskSource, - #[ignore_heap_size_of = "task sources are hard"] - file_reading_task_source: FileReadingTaskSource, + #[ignore_heap_size_of = "thread sources are hard"] + dom_manipulation_thread_source: DOMManipulationThreadSource, + #[ignore_heap_size_of = "thread sources are hard"] + user_interaction_thread_source: UserInteractionThreadSource, + #[ignore_heap_size_of = "thread sources are hard"] + networking_thread_source: NetworkingThreadSource, + #[ignore_heap_size_of = "thread sources are hard"] + history_traversal_thread_source: HistoryTraversalThreadSource, + #[ignore_heap_size_of = "thread sources are hard"] + file_reading_thread_source: FileReadingThreadSource, console: MutNullableHeap>, crypto: MutNullableHeap>, navigator: MutNullableHeap>, #[ignore_heap_size_of = "channels are hard"] - image_cache_task: ImageCacheTask, + image_cache_thread: ImageCacheThread, #[ignore_heap_size_of = "channels are hard"] image_cache_chan: ImageCacheChan, #[ignore_heap_size_of = "TODO(#6911) newtypes containing unmeasurable types are hard"] @@ -185,7 +185,7 @@ pub struct Window { #[ignore_heap_size_of = "Rc is hard"] js_runtime: DOMRefCell>>, - /// A handle for communicating messages to the layout task. + /// A handle for communicating messages to the layout thread. #[ignore_heap_size_of = "channels are hard"] layout_chan: LayoutChan, @@ -196,15 +196,15 @@ pub struct Window { /// The current size of the window, in pixels. window_size: Cell>, - /// Associated resource task for use by DOM objects like XMLHttpRequest + /// Associated resource thread for use by DOM objects like XMLHttpRequest #[ignore_heap_size_of = "channels are hard"] - resource_task: Arc, + resource_thread: Arc, - /// A handle for communicating messages to the storage task. + /// A handle for communicating messages to the storage thread. #[ignore_heap_size_of = "channels are hard"] - storage_task: StorageTask, + storage_thread: StorageThread, - /// A handle for communicating messages to the constellation task. + /// A handle for communicating messages to the constellation thread. #[ignore_heap_size_of = "channels are hard"] constellation_chan: ConstellationChan, @@ -249,24 +249,24 @@ impl Window { self.js_runtime.borrow().as_ref().unwrap().cx() } - pub fn dom_manipulation_task_source(&self) -> Box { - self.dom_manipulation_task_source.clone() + pub fn dom_manipulation_thread_source(&self) -> Box { + self.dom_manipulation_thread_source.clone() } - pub fn user_interaction_task_source(&self) -> Box { - self.user_interaction_task_source.clone() + pub fn user_interaction_thread_source(&self) -> Box { + self.user_interaction_thread_source.clone() } - pub fn networking_task_source(&self) -> Box { - self.networking_task_source.clone() + pub fn networking_thread_source(&self) -> Box { + self.networking_thread_source.clone() } - pub fn history_traversal_task_source(&self) -> Box { - self.history_traversal_task_source.clone() + pub fn history_traversal_thread_source(&self) -> Box { + self.history_traversal_thread_source.clone() } - pub fn file_reading_task_source(&self) -> Box { - self.file_reading_task_source.clone() + pub fn file_reading_thread_source(&self) -> Box { + self.file_reading_thread_source.clone() } pub fn main_thread_script_chan(&self) -> &Sender { @@ -302,8 +302,8 @@ impl Window { (box SendableMainThreadScriptChan(tx), box rx) } - pub fn image_cache_task(&self) -> &ImageCacheTask { - &self.image_cache_task + pub fn image_cache_thread(&self) -> &ImageCacheThread { + &self.image_cache_thread } pub fn compositor(&self) -> &IpcSender { @@ -318,8 +318,8 @@ impl Window { &*self.page } - pub fn storage_task(&self) -> StorageTask { - self.storage_task.clone() + pub fn storage_thread(&self) -> StorageThread { + self.storage_thread.clone() } pub fn css_error_reporter(&self) -> Box { @@ -837,10 +837,10 @@ impl Window { // (e.g. DOM objects removed from the tree that haven't // been collected yet). Forcing a GC here means that // those DOM objects will be able to call dispose() - // to free their layout data before the layout task + // to free their layout data before the layout thread // exits. Without this, those remaining objects try to // send a message to free their layout data to the - // layout task when the script task is dropped, + // layout thread when the script thread is dropped, // which causes a panic! self.Gc(); @@ -981,7 +981,7 @@ impl Window { } Ok(_) => {} Err(Disconnected) => { - panic!("Layout task failed while script was waiting for a result."); + panic!("Layout thread failed while script was waiting for a result."); } } @@ -1018,7 +1018,7 @@ impl Window { // 2) The html element doesn't contain the 'reftest-wait' class // 3) The load event has fired. // When all these conditions are met, notify the constellation - // that this pipeline is ready to write the image (from the script task + // that this pipeline is ready to write the image (from the script thread // perspective at least). if opts::get().output_file.is_some() && for_display { let document = self.Document(); @@ -1126,8 +1126,8 @@ impl Window { (*self.Document().url()).clone() } - pub fn resource_task(&self) -> ResourceTask { - (*self.resource_task).clone() + pub fn resource_thread(&self) -> ResourceThread { + (*self.resource_thread).clone() } pub fn mem_profiler_chan(&self) -> mem::ProfilerChan { @@ -1288,16 +1288,16 @@ impl Window { pub fn new(runtime: Rc, page: Rc, script_chan: MainThreadScriptChan, - dom_task_source: DOMManipulationTaskSource, - user_task_source: UserInteractionTaskSource, - network_task_source: NetworkingTaskSource, - history_task_source: HistoryTraversalTaskSource, - file_task_source: FileReadingTaskSource, + dom_thread_source: DOMManipulationThreadSource, + user_thread_source: UserInteractionThreadSource, + network_thread_source: NetworkingThreadSource, + history_thread_source: HistoryTraversalThreadSource, + file_thread_source: FileReadingThreadSource, image_cache_chan: ImageCacheChan, compositor: IpcSender, - image_cache_task: ImageCacheTask, - resource_task: Arc, - storage_task: StorageTask, + image_cache_thread: ImageCacheThread, + resource_thread: Arc, + storage_thread: StorageThread, mem_profiler_chan: mem::ProfilerChan, devtools_chan: Option>, constellation_chan: ConstellationChan, @@ -1318,18 +1318,18 @@ impl Window { let win = box Window { eventtarget: EventTarget::new_inherited(), script_chan: script_chan, - dom_manipulation_task_source: dom_task_source, - user_interaction_task_source: user_task_source, - networking_task_source: network_task_source, - history_traversal_task_source: history_task_source, - file_reading_task_source: file_task_source, + dom_manipulation_thread_source: dom_thread_source, + user_interaction_thread_source: user_thread_source, + networking_thread_source: network_thread_source, + history_traversal_thread_source: history_thread_source, + file_reading_thread_source: file_thread_source, image_cache_chan: image_cache_chan, console: Default::default(), crypto: Default::default(), compositor: compositor, page: page, navigator: Default::default(), - image_cache_task: image_cache_task, + image_cache_thread: image_cache_thread, mem_profiler_chan: mem_profiler_chan, devtools_chan: devtools_chan, browsing_context: Default::default(), @@ -1346,8 +1346,8 @@ impl Window { parent_info: parent_info, dom_static: GlobalStaticData::new(), js_runtime: DOMRefCell::new(Some(runtime.clone())), - resource_task: resource_task, - storage_task: storage_task, + resource_thread: resource_thread, + storage_thread: storage_thread, constellation_chan: constellation_chan, page_clip_rect: Cell::new(MAX_RECT), fragment_name: DOMRefCell::new(None), diff --git a/components/script/dom/worker.rs b/components/script/dom/worker.rs index 5ca3d3316fc..362874643bc 100644 --- a/components/script/dom/worker.rs +++ b/components/script/dom/worker.rs @@ -24,7 +24,7 @@ use ipc_channel::ipc; use js::jsapi::{HandleValue, JSContext, RootedValue}; use js::jsapi::{JSAutoCompartment, JSAutoRequest}; use js::jsval::UndefinedValue; -use script_task::{Runnable, ScriptChan}; +use script_thread::{Runnable, ScriptChan}; use std::sync::mpsc::{Sender, channel}; use util::str::DOMString; @@ -68,13 +68,13 @@ impl Worker { Err(_) => return Err(Error::Syntax), }; - let resource_task = global.resource_task(); + let resource_thread = global.resource_thread(); let constellation_chan = global.constellation_chan(); let scheduler_chan = global.scheduler_chan(); let (sender, receiver) = channel(); let worker = Worker::new(global, sender.clone()); - let worker_ref = Trusted::new(worker.r(), global.dom_manipulation_task_source()); + let worker_ref = Trusted::new(worker.r(), global.dom_manipulation_thread_source()); let worker_id = global.get_next_worker_id(); let (devtools_sender, devtools_receiver) = ipc::channel().unwrap(); @@ -95,7 +95,7 @@ impl Worker { }; let init = WorkerGlobalScopeInit { - resource_task: resource_task, + resource_thread: resource_thread, mem_profiler_chan: global.mem_profiler_chan(), to_devtools_sender: global.devtools_chan(), from_devtools_sender: optional_sender, @@ -105,7 +105,7 @@ impl Worker { }; DedicatedWorkerGlobalScope::run_worker_scope( init, worker_url, global.pipeline(), devtools_receiver, worker_ref, - global.dom_manipulation_task_source(), sender, receiver); + global.dom_manipulation_thread_source(), sender, receiver); Ok(worker) } @@ -145,7 +145,7 @@ impl WorkerMethods for Worker { // https://html.spec.whatwg.org/multipage/#dom-dedicatedworkerglobalscope-postmessage fn PostMessage(&self, cx: *mut JSContext, message: HandleValue) -> ErrorResult { let data = try!(StructuredCloneData::write(cx, message)); - let address = Trusted::new(self, self.global.root().r().dom_manipulation_task_source()); + let address = Trusted::new(self, self.global.root().r().dom_manipulation_thread_source()); self.sender.send((address, WorkerScriptMsg::DOMMessage(data))).unwrap(); Ok(()) } diff --git a/components/script/dom/workerglobalscope.rs b/components/script/dom/workerglobalscope.rs index 3224c04d57f..360c78099dd 100644 --- a/components/script/dom/workerglobalscope.rs +++ b/components/script/dom/workerglobalscope.rs @@ -21,9 +21,9 @@ use ipc_channel::ipc::IpcSender; use js::jsapi::{HandleValue, JSAutoRequest, JSContext}; use js::rust::Runtime; use msg::constellation_msg::{ConstellationChan, PipelineId}; -use net_traits::{LoadContext, ResourceTask, load_whole_resource}; +use net_traits::{LoadContext, ResourceThread, load_whole_resource}; use profile_traits::mem; -use script_task::{CommonScriptMsg, ScriptChan, ScriptPort}; +use script_thread::{CommonScriptMsg, ScriptChan, ScriptPort}; use script_traits::ScriptMsg as ConstellationMsg; use script_traits::{MsDuration, TimerEvent, TimerEventId, TimerEventRequest, TimerSource}; use std::cell::Cell; @@ -40,7 +40,7 @@ pub enum WorkerGlobalScopeTypeId { } pub struct WorkerGlobalScopeInit { - pub resource_task: ResourceTask, + pub resource_thread: ResourceThread, pub mem_profiler_chan: mem::ProfilerChan, pub to_devtools_sender: Option>, pub from_devtools_sender: Option>, @@ -59,7 +59,7 @@ pub struct WorkerGlobalScope { runtime: Rc, next_worker_id: Cell, #[ignore_heap_size_of = "Defined in std"] - resource_task: ResourceTask, + resource_thread: ResourceThread, location: MutNullableHeap>, navigator: MutNullableHeap>, console: MutNullableHeap>, @@ -104,7 +104,7 @@ impl WorkerGlobalScope { worker_id: init.worker_id, worker_url: worker_url, runtime: runtime, - resource_task: init.resource_task, + resource_thread: init.resource_thread, location: Default::default(), navigator: Default::default(), console: Default::default(), @@ -158,8 +158,8 @@ impl WorkerGlobalScope { self.runtime.cx() } - pub fn resource_task(&self) -> &ResourceTask { - &self.resource_task + pub fn resource_thread(&self) -> &ResourceThread { + &self.resource_thread } pub fn get_url(&self) -> &Url { @@ -203,7 +203,7 @@ impl WorkerGlobalScopeMethods for WorkerGlobalScope { } for url in urls { - let (url, source) = match load_whole_resource(LoadContext::Script, &self.resource_task, url, None) { + let (url, source) = match load_whole_resource(LoadContext::Script, &self.resource_thread, url, None) { Err(_) => return Err(Error::Network), Ok((metadata, bytes)) => { (metadata.final_url, String::from_utf8(bytes).unwrap()) diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs index cac963c85d9..854c9887d30 100644 --- a/components/script/dom/xmlhttprequest.rs +++ b/components/script/dom/xmlhttprequest.rs @@ -46,11 +46,11 @@ use js::jsapi::{JSContext, JS_ParseJSON, RootedValue}; use js::jsval::{JSVal, NullValue, UndefinedValue}; use net_traits::ControlMsg::Load; use net_traits::{AsyncResponseListener, AsyncResponseTarget, Metadata}; -use net_traits::{LoadConsumer, LoadContext, LoadData, ResourceCORSData, ResourceTask}; +use net_traits::{LoadConsumer, LoadContext, LoadData, ResourceCORSData, ResourceThread}; use network_listener::{NetworkListener, PreInvoke}; use parse::html::{ParseContext, parse_html}; use parse::xml::{self, parse_xml}; -use script_task::{ScriptChan, ScriptPort}; +use script_thread::{ScriptChan, ScriptPort}; use std::ascii::AsciiExt; use std::borrow::ToOwned; use std::cell::{Cell, RefCell}; @@ -197,13 +197,13 @@ impl XMLHttpRequest { load_data: LoadData, req: CORSRequest, script_chan: Box, - resource_task: ResourceTask) { + resource_thread: ResourceThread) { struct CORSContext { xhr: Arc>, load_data: RefCell>, req: CORSRequest, script_chan: Box, - resource_task: ResourceTask, + resource_thread: ResourceThread, } impl AsyncCORSResponseListener for CORSContext { @@ -223,7 +223,7 @@ impl XMLHttpRequest { }); XMLHttpRequest::initiate_async_xhr(self.xhr.clone(), self.script_chan.clone(), - self.resource_task.clone(), load_data); + self.resource_thread.clone(), load_data); } } @@ -232,7 +232,7 @@ impl XMLHttpRequest { load_data: RefCell::new(Some(load_data)), req: req.clone(), script_chan: script_chan.clone(), - resource_task: resource_task, + resource_thread: resource_thread, }; req.http_fetch_async(box cors_context, script_chan); @@ -240,7 +240,7 @@ impl XMLHttpRequest { fn initiate_async_xhr(context: Arc>, script_chan: Box, - resource_task: ResourceTask, + resource_thread: ResourceThread, load_data: LoadData) { impl AsyncResponseListener for XHRContext { fn headers_available(&mut self, metadata: Metadata) { @@ -281,7 +281,7 @@ impl XMLHttpRequest { ROUTER.add_route(action_receiver.to_opaque(), box move |message| { listener.notify(message.to().unwrap()); }); - resource_task.send(Load(load_data, LoadConsumer::Listener(response_target), None)).unwrap(); + resource_thread.send(Load(load_data, LoadConsumer::Listener(response_target), None)).unwrap(); } } @@ -1026,7 +1026,7 @@ impl XMLHttpRequest { // This will cancel all previous timeouts let global = self.global.root(); let callback = ScheduledXHRTimeout { - xhr: Trusted::new(self, global.r().networking_task_source()), + xhr: Trusted::new(self, global.r().networking_thread_source()), generation_id: self.generation_id.get(), }; let duration = Length::new(duration_ms as u64); @@ -1178,7 +1178,7 @@ impl XMLHttpRequest { Ok(req) => req, }; - let xhr = Trusted::new(self, global.networking_task_source()); + let xhr = Trusted::new(self, global.networking_thread_source()); let context = Arc::new(Mutex::new(XHRContext { xhr: xhr, @@ -1192,16 +1192,16 @@ impl XMLHttpRequest { let (tx, rx) = global.new_script_pair(); (tx, Some(rx)) } else { - (global.networking_task_source(), None) + (global.networking_thread_source(), None) }; - let resource_task = global.resource_task(); + let resource_thread = global.resource_thread(); if let Some(req) = cors_request { XMLHttpRequest::check_cors(context.clone(), load_data, req.clone(), - script_chan.clone(), resource_task); + script_chan.clone(), resource_thread); } else { XMLHttpRequest::initiate_async_xhr(context.clone(), script_chan, - resource_task, load_data); + resource_thread, load_data); } if let Some(script_port) = script_port { diff --git a/components/script/layout_interface.rs b/components/script/layout_interface.rs index 5f6fd653a7e..9d407c4e8b2 100644 --- a/components/script/layout_interface.rs +++ b/components/script/layout_interface.rs @@ -15,7 +15,7 @@ use ipc_channel::ipc::{IpcReceiver, IpcSender}; use msg::compositor_msg::Epoch; use msg::constellation_msg::{ConstellationChan, Failure, PipelineId}; use msg::constellation_msg::{WindowSizeData}; -use net_traits::image_cache_task::ImageCacheTask; +use net_traits::image_cache_thread::ImageCacheThread; use profile_traits::mem::ReportsChan; use script_traits::{ConstellationControlMsg, LayoutControlMsg, LayoutMsg as ConstellationMsg}; use script_traits::{OpaqueScriptLayoutChannel, UntrustedNodeAddress}; @@ -46,10 +46,10 @@ pub enum Msg { /// Get an RPC interface. GetRPC(Sender>), - /// Requests that the layout task render the next frame of all animations. + /// Requests that the layout thread render the next frame of all animations. TickAnimations, - /// Requests that the layout task reflow with a newly-loaded Web font. + /// Requests that the layout thread reflow with a newly-loaded Web font. ReflowWithNewlyLoadedWebFont, /// Updates the layout visible rects, affecting the area that display lists will be constructed @@ -61,30 +61,30 @@ pub enum Msg { /// TODO(pcwalton): Maybe think about batching to avoid message traffic. ReapStyleAndLayoutData(OpaqueStyleAndLayoutData), - /// Requests that the layout task measure its memory usage. The resulting reports are sent back + /// Requests that the layout thread measure its memory usage. The resulting reports are sent back /// via the supplied channel. CollectReports(ReportsChan), - /// Requests that the layout task enter a quiescent state in which no more messages are + /// Requests that the layout thread enter a quiescent state in which no more messages are /// accepted except `ExitMsg`. A response message will be sent on the supplied channel when /// this happens. PrepareToExit(Sender<()>), - /// Requests that the layout task immediately shut down. There must be no more nodes left after + /// Requests that the layout thread immediately shut down. There must be no more nodes left after /// this, or layout will crash. ExitNow, - /// Get the last epoch counter for this layout task. + /// Get the last epoch counter for this layout thread. GetCurrentEpoch(IpcSender), - /// Asks the layout task whether any Web fonts have yet to load (if true, loads are pending; + /// Asks the layout thread whether any Web fonts have yet to load (if true, loads are pending; /// false otherwise). GetWebFontLoadState(IpcSender), - /// Creates a new layout task. + /// Creates a new layout thread. /// /// This basically exists to keep the script-layout dependency one-way. - CreateLayoutTask(NewLayoutTaskInfo), + CreateLayoutThread(NewLayoutThreadInfo), /// Set the final Url. SetFinalUrl(Url), @@ -95,7 +95,7 @@ pub enum Msg { /// In general, you should use messages to talk to Layout. Use the RPC interface /// if and only if the work is /// -/// 1) read-only with respect to LayoutTaskData, +/// 1) read-only with respect to LayoutThreadData, /// 2) small, /// 3) and really needs to be fast. pub trait LayoutRPC { @@ -181,7 +181,7 @@ impl Drop for ScriptReflow { } } -/// Encapsulates a channel to the layout task. +/// Encapsulates a channel to the layout thread. #[derive(Clone)] pub struct LayoutChan(pub Sender); @@ -217,7 +217,7 @@ impl ScriptLayoutChan for OpaqueScriptLayoutChannel { } } -pub struct NewLayoutTaskInfo { +pub struct NewLayoutThreadInfo { pub id: PipelineId, pub url: Url, pub is_parent: bool, @@ -226,7 +226,7 @@ pub struct NewLayoutTaskInfo { pub constellation_chan: ConstellationChan, pub failure: Failure, pub script_chan: IpcSender, - pub image_cache_task: ImageCacheTask, + pub image_cache_thread: ImageCacheThread, pub paint_chan: OptionalOpaqueIpcSender, pub layout_shutdown_chan: IpcSender<()>, pub content_process_shutdown_chan: IpcSender<()>, diff --git a/components/script/lib.rs b/components/script/lib.rs index 71afdb02df4..24483d3182f 100644 --- a/components/script/lib.rs +++ b/components/script/lib.rs @@ -92,7 +92,7 @@ pub mod page; pub mod parse; pub mod reporter; #[allow(unsafe_code)] -pub mod script_task; +pub mod script_thread; pub mod textinput; mod timers; mod unpremultiplytable; @@ -147,7 +147,7 @@ fn perform_platform_specific_initialization() {} pub fn init() { unsafe { assert_eq!(js::jsapi::JS_Init(), true); - SetDOMProxyInformation(ptr::null(), 0, Some(script_task::shadow_check_callback)); + SetDOMProxyInformation(ptr::null(), 0, Some(script_thread::shadow_check_callback)); } // Create the global vtables used by the (generated) DOM diff --git a/components/script/network_listener.rs b/components/script/network_listener.rs index d16517230bc..448befa0f51 100644 --- a/components/script/network_listener.rs +++ b/components/script/network_listener.rs @@ -3,8 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use net_traits::{AsyncResponseListener, ResponseAction}; -use script_task::ScriptTaskEventCategory::NetworkEvent; -use script_task::{CommonScriptMsg, Runnable, ScriptChan}; +use script_thread::ScriptThreadEventCategory::NetworkEvent; +use script_thread::{CommonScriptMsg, Runnable, ScriptChan}; use std::sync::{Arc, Mutex}; /// An off-thread sink for async network event runnables. All such events are forwarded to diff --git a/components/script/script_task.rs b/components/script/script_thread.rs similarity index 85% rename from components/script/script_task.rs rename to components/script/script_thread.rs index 910d1e785f8..f0ed7ac22d6 100644 --- a/components/script/script_task.rs +++ b/components/script/script_thread.rs @@ -2,19 +2,19 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -//! The script task is the task that owns the DOM in memory, runs JavaScript, and spawns parsing -//! and layout tasks. It's in charge of processing events for all same-origin pages in a frame +//! The script thread is the thread that owns the DOM in memory, runs JavaScript, and spawns parsing +//! and layout threads. It's in charge of processing events for all same-origin pages in a frame //! tree, and manages the entire lifetime of pages in the frame tree from initial request to //! teardown. //! //! Page loads follow a two-step process. When a request for a new page load is received, the //! network request is initiated and the relevant data pertaining to the new page is stashed. -//! While the non-blocking request is ongoing, the script task is free to process further events, +//! While the non-blocking request is ongoing, the script thread is free to process further events, //! noting when they pertain to ongoing loads (such as resizes/viewport adjustments). When the //! initial response is received for an ongoing load, the second phase starts - the frame tree //! entry is created, along with the Window and Document objects, and the appropriate parser //! takes over the response body. Once parsing is complete, the document lifecycle for loading -//! a page runs its course and the script task returns to processing events in the main event +//! a page runs its course and the script thread returns to processing events in the main event //! loop. use devtools; @@ -59,7 +59,7 @@ use js::jsapi::{JSObject, SetPreserveWrapperCallback}; use js::jsval::UndefinedValue; use js::rust::Runtime; use layout_interface::{ReflowQueryType}; -use layout_interface::{self, LayoutChan, NewLayoutTaskInfo, ReflowGoal, ScriptLayoutChan}; +use layout_interface::{self, LayoutChan, NewLayoutThreadInfo, ReflowGoal, ScriptLayoutChan}; use libc; use mem::heap_size_of_self_and_children; use msg::constellation_msg::{ConstellationChan, LoadData}; @@ -68,9 +68,9 @@ use msg::constellation_msg::{PipelineNamespace}; use msg::constellation_msg::{SubpageId, WindowSizeData}; use msg::webdriver_msg::WebDriverScriptCommand; use net_traits::LoadData as NetLoadData; -use net_traits::image_cache_task::{ImageCacheChan, ImageCacheResult, ImageCacheTask}; -use net_traits::storage_task::StorageTask; -use net_traits::{AsyncResponseTarget, ControlMsg, LoadConsumer, LoadContext, Metadata, ResourceTask}; +use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheResult, ImageCacheThread}; +use net_traits::storage_thread::StorageThread; +use net_traits::{AsyncResponseTarget, ControlMsg, LoadConsumer, LoadContext, Metadata, ResourceThread}; use network_listener::NetworkListener; use page::{Frame, IterablePage, Page}; use parse::html::{ParseContext, parse_html}; @@ -81,7 +81,7 @@ use script_traits::CompositorEvent::{KeyEvent, MouseButtonEvent, MouseMoveEvent, use script_traits::CompositorEvent::{TouchEvent}; use script_traits::{CompositorEvent, ConstellationControlMsg, EventResult, InitialScriptState, NewLayoutInfo}; use script_traits::{LayoutMsg, OpaqueScriptLayoutChannel, ScriptMsg as ConstellationMsg}; -use script_traits::{ScriptTaskFactory, ScriptToCompositorMsg, TimerEvent, TimerEventRequest, TimerSource}; +use script_traits::{ScriptThreadFactory, ScriptToCompositorMsg, TimerEvent, TimerEventRequest, TimerSource}; use script_traits::{TouchEventType, TouchId}; use std::any::Any; use std::borrow::ToOwned; @@ -101,17 +101,17 @@ use time::{Tm, now}; use url::Url; use util::opts; use util::str::DOMString; -use util::task; -use util::task_state; +use util::thread; +use util::thread_state; use webdriver_handlers; thread_local!(pub static STACK_ROOTS: Cell> = Cell::new(None)); -thread_local!(static SCRIPT_TASK_ROOT: RefCell> = RefCell::new(None)); +thread_local!(static SCRIPT_TASK_ROOT: RefCell> = RefCell::new(None)); unsafe extern fn trace_rust_roots(tr: *mut JSTracer, _data: *mut libc::c_void) { SCRIPT_TASK_ROOT.with(|root| { - if let Some(script_task) = *root.borrow() { - (*script_task).trace(tr); + if let Some(script_thread) = *root.borrow() { + (*script_thread).trace(tr); } }); @@ -131,7 +131,7 @@ struct InProgressLoad { parent_info: Option<(PipelineId, SubpageId)>, /// The current window size associated with this pipeline. window_size: Option, - /// Channel to the layout task associated with this pipeline. + /// Channel to the layout thread associated with this pipeline. layout_chan: LayoutChan, /// The current viewport clipping rectangle applying to this pipeline, if any. clip_rect: Option>, @@ -196,7 +196,7 @@ pub trait Runnable { } pub trait MainThreadRunnable { - fn handler(self: Box, script_task: &ScriptTask); + fn handler(self: Box, script_thread: &ScriptThread); } enum MixedMessage { @@ -209,17 +209,17 @@ enum MixedMessage { /// Common messages used to control the event loops in both the script and the worker pub enum CommonScriptMsg { - /// Requests that the script task measure its memory usage. The results are sent back via the + /// Requests that the script thread measure its memory usage. The results are sent back via the /// supplied channel. CollectReports(ReportsChan), - /// A DOM object's last pinned reference was removed (dispatched to all tasks). + /// A DOM object's last pinned reference was removed (dispatched to all threads). RefcountCleanup(TrustedReference), /// Generic message that encapsulates event handling. - RunnableMsg(ScriptTaskEventCategory, Box), + RunnableMsg(ScriptThreadEventCategory, Box), } #[derive(Clone, Copy, Debug, Eq, Hash, JSTraceable, PartialEq)] -pub enum ScriptTaskEventCategory { +pub enum ScriptThreadEventCategory { AttachLayout, ConstellationMsg, DevtoolsMsg, @@ -246,12 +246,12 @@ pub enum MainThreadScriptMsg { /// Notify a document that all pending loads are complete. DocumentLoadsComplete(PipelineId), /// Notifies the script that a window associated with a particular pipeline - /// should be closed (only dispatched to ScriptTask). + /// should be closed (only dispatched to ScriptThread). ExitWindow(PipelineId), - /// Generic message for running tasks in the ScriptTask + /// Generic message for running threads in the ScriptThread MainThreadRunnableMsg(Box), /// Begins a content-initiated load on the specified pipeline (only - /// dispatched to ScriptTask). + /// dispatched to ScriptThread). Navigate(PipelineId, LoadData), } @@ -306,7 +306,7 @@ impl ScriptPort for Receiver<(TrustedWorkerAddress, MainThreadScriptMsg)> { } } -/// Encapsulates internal communication of shared messages within the script task. +/// Encapsulates internal communication of shared messages within the script thread. #[derive(JSTraceable)] pub struct SendableMainThreadScriptChan(pub Sender); @@ -330,7 +330,7 @@ impl SendableMainThreadScriptChan { } } -/// Encapsulates internal communication of main thread messages within the script task. +/// Encapsulates internal communication of main thread messages within the script thread. #[derive(JSTraceable)] pub struct MainThreadScriptChan(pub Sender); @@ -354,99 +354,99 @@ impl MainThreadScriptChan { } } -// FIXME: Use a task source specific message instead of MainThreadScriptMsg +// FIXME: Use a thread source specific message instead of MainThreadScriptMsg #[derive(JSTraceable)] -pub struct DOMManipulationTaskSource(pub Sender); +pub struct DOMManipulationThreadSource(pub Sender); -impl ScriptChan for DOMManipulationTaskSource { +impl ScriptChan for DOMManipulationThreadSource { fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> { - let DOMManipulationTaskSource(ref chan) = *self; + let DOMManipulationThreadSource(ref chan) = *self; chan.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ()) } fn clone(&self) -> Box { - let DOMManipulationTaskSource(ref chan) = *self; - box DOMManipulationTaskSource((*chan).clone()) + let DOMManipulationThreadSource(ref chan) = *self; + box DOMManipulationThreadSource((*chan).clone()) } } -// FIXME: Use a task source specific message instead of MainThreadScriptMsg +// FIXME: Use a thread source specific message instead of MainThreadScriptMsg #[derive(JSTraceable)] -pub struct UserInteractionTaskSource(pub Sender); +pub struct UserInteractionThreadSource(pub Sender); -impl ScriptChan for UserInteractionTaskSource { +impl ScriptChan for UserInteractionThreadSource { fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> { - let UserInteractionTaskSource(ref chan) = *self; + let UserInteractionThreadSource(ref chan) = *self; chan.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ()) } fn clone(&self) -> Box { - let UserInteractionTaskSource(ref chan) = *self; - box UserInteractionTaskSource((*chan).clone()) + let UserInteractionThreadSource(ref chan) = *self; + box UserInteractionThreadSource((*chan).clone()) } } -// FIXME: Use a task source specific message instead of MainThreadScriptMsg +// FIXME: Use a thread source specific message instead of MainThreadScriptMsg #[derive(JSTraceable)] -pub struct NetworkingTaskSource(pub Sender); +pub struct NetworkingThreadSource(pub Sender); -impl ScriptChan for NetworkingTaskSource { +impl ScriptChan for NetworkingThreadSource { fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> { - let NetworkingTaskSource(ref chan) = *self; + let NetworkingThreadSource(ref chan) = *self; chan.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ()) } fn clone(&self) -> Box { - let NetworkingTaskSource(ref chan) = *self; - box NetworkingTaskSource((*chan).clone()) + let NetworkingThreadSource(ref chan) = *self; + box NetworkingThreadSource((*chan).clone()) } } -// FIXME: Use a task source specific message instead of MainThreadScriptMsg +// FIXME: Use a thread source specific message instead of MainThreadScriptMsg #[derive(JSTraceable)] -pub struct HistoryTraversalTaskSource(pub Sender); +pub struct HistoryTraversalThreadSource(pub Sender); -impl ScriptChan for HistoryTraversalTaskSource { +impl ScriptChan for HistoryTraversalThreadSource { fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> { - let HistoryTraversalTaskSource(ref chan) = *self; + let HistoryTraversalThreadSource(ref chan) = *self; chan.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ()) } fn clone(&self) -> Box { - let HistoryTraversalTaskSource(ref chan) = *self; - box HistoryTraversalTaskSource((*chan).clone()) + let HistoryTraversalThreadSource(ref chan) = *self; + box HistoryTraversalThreadSource((*chan).clone()) } } -// FIXME: Use a task source specific message instead of MainThreadScriptMsg +// FIXME: Use a thread source specific message instead of MainThreadScriptMsg #[derive(JSTraceable)] -pub struct FileReadingTaskSource(pub Sender); +pub struct FileReadingThreadSource(pub Sender); -impl ScriptChan for FileReadingTaskSource { +impl ScriptChan for FileReadingThreadSource { fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> { - let FileReadingTaskSource(ref chan) = *self; + let FileReadingThreadSource(ref chan) = *self; chan.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ()) } fn clone(&self) -> Box { - let FileReadingTaskSource(ref chan) = *self; - box FileReadingTaskSource((*chan).clone()) + let FileReadingThreadSource(ref chan) = *self; + box FileReadingThreadSource((*chan).clone()) } } -// FIXME: Use a task source specific message instead of MainThreadScriptMsg +// FIXME: Use a thread source specific message instead of MainThreadScriptMsg #[derive(JSTraceable)] -pub struct ProfilerTaskSource(pub Sender); +pub struct ProfilerThreadSource(pub Sender); -impl ScriptChan for ProfilerTaskSource { +impl ScriptChan for ProfilerThreadSource { fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> { - let ProfilerTaskSource(ref chan) = *self; + let ProfilerThreadSource(ref chan) = *self; chan.send(MainThreadScriptMsg::Common(msg)).map_err(|_| ()) } fn clone(&self) -> Box { - let ProfilerTaskSource(ref chan) = *self; - box ProfilerTaskSource((*chan).clone()) + let ProfilerThreadSource(ref chan) = *self; + box ProfilerThreadSource((*chan).clone()) } } @@ -471,41 +471,41 @@ impl<'a> Drop for StackRootTLS<'a> { /// Information for an entire page. Pages are top-level browsing contexts and can contain multiple /// frames. #[derive(JSTraceable)] -// ScriptTask instances are rooted on creation, so this is okay +// ScriptThread instances are rooted on creation, so this is okay #[allow(unrooted_must_root)] -pub struct ScriptTask { +pub struct ScriptThread { /// A handle to the information pertaining to page layout page: DOMRefCell>>, /// A list of data pertaining to loads that have not yet received a network response incomplete_loads: DOMRefCell>, - /// A handle to the image cache task. - image_cache_task: ImageCacheTask, - /// A handle to the resource task. This is an `Arc` to avoid running out of file descriptors if + /// A handle to the image cache thread. + image_cache_thread: ImageCacheThread, + /// A handle to the resource thread. This is an `Arc` to avoid running out of file descriptors if /// there are many iframes. - resource_task: Arc, - /// A handle to the storage task. - storage_task: StorageTask, + resource_thread: Arc, + /// A handle to the storage thread. + storage_thread: StorageThread, - /// The port on which the script task receives messages (load URL, exit, etc.) + /// The port on which the script thread receives messages (load URL, exit, etc.) port: Receiver, - /// A channel to hand out to script task-based entities that need to be able to enqueue + /// A channel to hand out to script thread-based entities that need to be able to enqueue /// events in the event queue. chan: MainThreadScriptChan, - dom_manipulation_task_source: DOMManipulationTaskSource, + dom_manipulation_thread_source: DOMManipulationThreadSource, - user_interaction_task_source: UserInteractionTaskSource, + user_interaction_thread_source: UserInteractionThreadSource, - networking_task_source: NetworkingTaskSource, + networking_thread_source: NetworkingThreadSource, - history_traversal_task_source: HistoryTraversalTaskSource, + history_traversal_thread_source: HistoryTraversalThreadSource, - file_reading_task_source: FileReadingTaskSource, + file_reading_thread_source: FileReadingThreadSource, - /// A channel to hand out to tasks that need to respond to a message from the script task. + /// A channel to hand out to threads that need to respond to a message from the script thread. control_chan: IpcSender, - /// The port on which the constellation and layout tasks can communicate with the - /// script task. + /// The port on which the constellation and layout threads can communicate with the + /// script thread. control_port: Receiver, /// For communicating load url messages to the constellation @@ -541,7 +541,7 @@ pub struct ScriptTask { mouse_over_targets: DOMRefCell>>, - /// List of pipelines that have been owned and closed by this script task. + /// List of pipelines that have been owned and closed by this script thread. closed_pipelines: DOMRefCell>, scheduler_chan: IpcSender, @@ -551,12 +551,12 @@ pub struct ScriptTask { content_process_shutdown_chan: IpcSender<()>, } -/// In the event of task failure, all data on the stack runs its destructor. However, there +/// In the event of thread failure, all data on the stack runs its destructor. However, there /// are no reachable, owning pointers to the DOM memory, so it never gets freed by default -/// when the script task fails. The ScriptMemoryFailsafe uses the destructor bomb pattern -/// to forcibly tear down the JS compartments for pages associated with the failing ScriptTask. +/// when the script thread fails. The ScriptMemoryFailsafe uses the destructor bomb pattern +/// to forcibly tear down the JS compartments for pages associated with the failing ScriptThread. struct ScriptMemoryFailsafe<'a> { - owner: Option<&'a ScriptTask>, + owner: Option<&'a ScriptThread>, } impl<'a> ScriptMemoryFailsafe<'a> { @@ -564,7 +564,7 @@ impl<'a> ScriptMemoryFailsafe<'a> { self.owner = None; } - fn new(owner: &'a ScriptTask) -> ScriptMemoryFailsafe<'a> { + fn new(owner: &'a ScriptThread) -> ScriptMemoryFailsafe<'a> { ScriptMemoryFailsafe { owner: Some(owner), } @@ -589,18 +589,18 @@ impl<'a> Drop for ScriptMemoryFailsafe<'a> { } } -impl ScriptTaskFactory for ScriptTask { - fn create_layout_channel(_phantom: Option<&mut ScriptTask>) -> OpaqueScriptLayoutChannel { +impl ScriptThreadFactory for ScriptThread { + fn create_layout_channel(_phantom: Option<&mut ScriptThread>) -> OpaqueScriptLayoutChannel { let (chan, port) = channel(); ScriptLayoutChan::new(chan, port) } - fn clone_layout_channel(_phantom: Option<&mut ScriptTask>, pair: &OpaqueScriptLayoutChannel) + fn clone_layout_channel(_phantom: Option<&mut ScriptThread>, pair: &OpaqueScriptLayoutChannel) -> Box { box pair.sender() as Box } - fn create(_phantom: Option<&mut ScriptTask>, + fn create(_phantom: Option<&mut ScriptThread>, state: InitialScriptState, layout_chan: &OpaqueScriptLayoutChannel, load_data: LoadData) { @@ -608,8 +608,8 @@ impl ScriptTaskFactory for ScriptTask { let (script_chan, script_port) = channel(); let layout_chan = LayoutChan(layout_chan.sender()); let failure_info = state.failure_info; - task::spawn_named_with_send_on_failure(format!("ScriptTask {:?}", state.id), - task_state::SCRIPT, + thread::spawn_named_with_send_on_failure(format!("ScriptThread {:?}", state.id), + thread_state::SCRIPT, move || { PipelineNamespace::install(state.pipeline_namespace_id); let roots = RootCollection::new(); @@ -620,27 +620,27 @@ impl ScriptTaskFactory for ScriptTask { let parent_info = state.parent_info; let mem_profiler_chan = state.mem_profiler_chan.clone(); let window_size = state.window_size; - let script_task = ScriptTask::new(state, + let script_thread = ScriptThread::new(state, script_port, script_chan); SCRIPT_TASK_ROOT.with(|root| { - *root.borrow_mut() = Some(&script_task as *const _); + *root.borrow_mut() = Some(&script_thread as *const _); }); - let mut failsafe = ScriptMemoryFailsafe::new(&script_task); + let mut failsafe = ScriptMemoryFailsafe::new(&script_thread); let new_load = InProgressLoad::new(id, parent_info, layout_chan, window_size, load_data.url.clone()); - script_task.start_page_load(new_load, load_data); + script_thread.start_page_load(new_load, load_data); let reporter_name = format!("script-reporter-{}", id); mem_profiler_chan.run_with_memory_reporting(|| { - script_task.start(); - let _ = script_task.content_process_shutdown_chan.send(()); + script_thread.start(); + let _ = script_thread.content_process_shutdown_chan.send(()); }, reporter_name, channel_for_reporter, CommonScriptMsg::CollectReports); - // This must always be the very last operation performed before the task completes + // This must always be the very last operation performed before the thread completes failsafe.neuter(); }, ConstellationMsg::Failure(failure_info), const_chan); } @@ -691,8 +691,8 @@ unsafe extern "C" fn gc_slice_callback(_rt: *mut JSRuntime, progress: GCProgress unsafe extern "C" fn debug_gc_callback(_rt: *mut JSRuntime, status: JSGCStatus, _data: *mut libc::c_void) { match status { - JSGCStatus::JSGC_BEGIN => task_state::enter(task_state::IN_GC), - JSGCStatus::JSGC_END => task_state::exit(task_state::IN_GC), + JSGCStatus::JSGC_BEGIN => thread_state::enter(thread_state::IN_GC), + JSGCStatus::JSGC_END => thread_state::exit(thread_state::IN_GC), } } @@ -710,37 +710,37 @@ pub struct CSSError { msg: String } -impl ScriptTask { +impl ScriptThread { pub fn page_fetch_complete(id: PipelineId, subpage: Option, metadata: Metadata) -> Option { SCRIPT_TASK_ROOT.with(|root| { - let script_task = unsafe { &*root.borrow().unwrap() }; - script_task.handle_page_fetch_complete(id, subpage, metadata) + let script_thread = unsafe { &*root.borrow().unwrap() }; + script_thread.handle_page_fetch_complete(id, subpage, metadata) }) } pub fn parsing_complete(id: PipelineId) { SCRIPT_TASK_ROOT.with(|root| { - let script_task = unsafe { &*root.borrow().unwrap() }; - script_task.handle_parsing_complete(id); + let script_thread = unsafe { &*root.borrow().unwrap() }; + script_thread.handle_parsing_complete(id); }); } pub fn process_event(msg: CommonScriptMsg) { SCRIPT_TASK_ROOT.with(|root| { - if let Some(script_task) = *root.borrow() { - let script_task = unsafe { &*script_task }; - script_task.handle_msg_from_script(MainThreadScriptMsg::Common(msg)); + if let Some(script_thread) = *root.borrow() { + let script_thread = unsafe { &*script_thread }; + script_thread.handle_msg_from_script(MainThreadScriptMsg::Common(msg)); } }); } - /// Creates a new script task. + /// Creates a new script thread. pub fn new(state: InitialScriptState, port: Receiver, chan: Sender) - -> ScriptTask { - let runtime = ScriptTask::new_rt_and_cx(); + -> ScriptThread { + let runtime = ScriptThread::new_rt_and_cx(); unsafe { JS_SetWrapObjectCallbacks(runtime.rt(), @@ -751,7 +751,7 @@ impl ScriptTask { let (ipc_devtools_sender, ipc_devtools_receiver) = ipc::channel().unwrap(); let devtools_port = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_devtools_receiver); - // Ask the router to proxy IPC messages from the image cache task to us. + // Ask the router to proxy IPC messages from the image cache thread to us. let (ipc_image_cache_channel, ipc_image_cache_port) = ipc::channel().unwrap(); let image_cache_port = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_image_cache_port); @@ -761,24 +761,24 @@ impl ScriptTask { // Ask the router to proxy IPC messages from the control port to us. let control_port = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(state.control_port); - ScriptTask { + ScriptThread { page: DOMRefCell::new(None), incomplete_loads: DOMRefCell::new(vec!()), - image_cache_task: state.image_cache_task, + image_cache_thread: state.image_cache_thread, image_cache_channel: ImageCacheChan(ipc_image_cache_channel), image_cache_port: image_cache_port, - resource_task: Arc::new(state.resource_task), - storage_task: state.storage_task, + resource_thread: Arc::new(state.resource_thread), + storage_thread: state.storage_thread, port: port, chan: MainThreadScriptChan(chan.clone()), - dom_manipulation_task_source: DOMManipulationTaskSource(chan.clone()), - user_interaction_task_source: UserInteractionTaskSource(chan.clone()), - networking_task_source: NetworkingTaskSource(chan.clone()), - history_traversal_task_source: HistoryTraversalTaskSource(chan.clone()), - file_reading_task_source: FileReadingTaskSource(chan), + dom_manipulation_thread_source: DOMManipulationThreadSource(chan.clone()), + user_interaction_thread_source: UserInteractionThreadSource(chan.clone()), + networking_thread_source: NetworkingThreadSource(chan.clone()), + history_traversal_thread_source: HistoryTraversalThreadSource(chan.clone()), + file_reading_thread_source: FileReadingThreadSource(chan), control_chan: state.control_chan, control_port: control_port, @@ -851,7 +851,7 @@ impl ScriptTask { self.js_runtime.cx() } - /// Starts the script task. After calling this method, the script task will loop receiving + /// Starts the script thread. After calling this method, the script thread will loop receiving /// messages on its port. pub fn start(&self) { while self.handle_msgs() { @@ -932,17 +932,17 @@ impl ScriptTask { // child list yet, causing the find() to fail. FromConstellation(ConstellationControlMsg::AttachLayout( new_layout_info)) => { - self.profile_event(ScriptTaskEventCategory::AttachLayout, || { + self.profile_event(ScriptThreadEventCategory::AttachLayout, || { self.handle_new_layout(new_layout_info); }) } FromConstellation(ConstellationControlMsg::Resize(id, size)) => { - self.profile_event(ScriptTaskEventCategory::Resize, || { + self.profile_event(ScriptThreadEventCategory::Resize, || { self.handle_resize(id, size); }) } FromConstellation(ConstellationControlMsg::Viewport(id, rect)) => { - self.profile_event(ScriptTaskEventCategory::SetViewport, || { + self.profile_event(ScriptThreadEventCategory::SetViewport, || { self.handle_viewport(id, rect); }) } @@ -1037,52 +1037,52 @@ impl ScriptTask { true } - fn categorize_msg(&self, msg: &MixedMessage) -> ScriptTaskEventCategory { + fn categorize_msg(&self, msg: &MixedMessage) -> ScriptThreadEventCategory { match *msg { MixedMessage::FromConstellation(ref inner_msg) => { match *inner_msg { ConstellationControlMsg::SendEvent(_, _) => - ScriptTaskEventCategory::DomEvent, - _ => ScriptTaskEventCategory::ConstellationMsg + ScriptThreadEventCategory::DomEvent, + _ => ScriptThreadEventCategory::ConstellationMsg } }, - MixedMessage::FromDevtools(_) => ScriptTaskEventCategory::DevtoolsMsg, - MixedMessage::FromImageCache(_) => ScriptTaskEventCategory::ImageCacheMsg, + MixedMessage::FromDevtools(_) => ScriptThreadEventCategory::DevtoolsMsg, + MixedMessage::FromImageCache(_) => ScriptThreadEventCategory::ImageCacheMsg, MixedMessage::FromScript(ref inner_msg) => { match *inner_msg { MainThreadScriptMsg::Common(CommonScriptMsg::RunnableMsg(ref category, _)) => *category, - _ => ScriptTaskEventCategory::ScriptEvent + _ => ScriptThreadEventCategory::ScriptEvent } }, - MixedMessage::FromScheduler(_) => ScriptTaskEventCategory::TimerEvent, + MixedMessage::FromScheduler(_) => ScriptThreadEventCategory::TimerEvent, } } - fn profile_event(&self, category: ScriptTaskEventCategory, f: F) -> R + fn profile_event(&self, category: ScriptThreadEventCategory, f: F) -> R where F: FnOnce() -> R { if opts::get().profile_script_events { let profiler_cat = match category { - ScriptTaskEventCategory::AttachLayout => ProfilerCategory::ScriptAttachLayout, - ScriptTaskEventCategory::ConstellationMsg => ProfilerCategory::ScriptConstellationMsg, - ScriptTaskEventCategory::DevtoolsMsg => ProfilerCategory::ScriptDevtoolsMsg, - ScriptTaskEventCategory::DocumentEvent => ProfilerCategory::ScriptDocumentEvent, - ScriptTaskEventCategory::DomEvent => ProfilerCategory::ScriptDomEvent, - ScriptTaskEventCategory::FileRead => ProfilerCategory::ScriptFileRead, - ScriptTaskEventCategory::ImageCacheMsg => ProfilerCategory::ScriptImageCacheMsg, - ScriptTaskEventCategory::InputEvent => ProfilerCategory::ScriptInputEvent, - ScriptTaskEventCategory::NetworkEvent => ProfilerCategory::ScriptNetworkEvent, - ScriptTaskEventCategory::Resize => ProfilerCategory::ScriptResize, - ScriptTaskEventCategory::ScriptEvent => ProfilerCategory::ScriptEvent, - ScriptTaskEventCategory::UpdateReplacedElement => { + ScriptThreadEventCategory::AttachLayout => ProfilerCategory::ScriptAttachLayout, + ScriptThreadEventCategory::ConstellationMsg => ProfilerCategory::ScriptConstellationMsg, + ScriptThreadEventCategory::DevtoolsMsg => ProfilerCategory::ScriptDevtoolsMsg, + ScriptThreadEventCategory::DocumentEvent => ProfilerCategory::ScriptDocumentEvent, + ScriptThreadEventCategory::DomEvent => ProfilerCategory::ScriptDomEvent, + ScriptThreadEventCategory::FileRead => ProfilerCategory::ScriptFileRead, + ScriptThreadEventCategory::ImageCacheMsg => ProfilerCategory::ScriptImageCacheMsg, + ScriptThreadEventCategory::InputEvent => ProfilerCategory::ScriptInputEvent, + ScriptThreadEventCategory::NetworkEvent => ProfilerCategory::ScriptNetworkEvent, + ScriptThreadEventCategory::Resize => ProfilerCategory::ScriptResize, + ScriptThreadEventCategory::ScriptEvent => ProfilerCategory::ScriptEvent, + ScriptThreadEventCategory::UpdateReplacedElement => { ProfilerCategory::ScriptUpdateReplacedElement } - ScriptTaskEventCategory::StylesheetLoad => ProfilerCategory::ScriptStylesheetLoad, - ScriptTaskEventCategory::SetViewport => ProfilerCategory::ScriptSetViewport, - ScriptTaskEventCategory::TimerEvent => ProfilerCategory::ScriptTimerEvent, - ScriptTaskEventCategory::WebSocketEvent => ProfilerCategory::ScriptWebSocketEvent, - ScriptTaskEventCategory::WorkerEvent => ProfilerCategory::ScriptWorkerEvent, + ScriptThreadEventCategory::StylesheetLoad => ProfilerCategory::ScriptStylesheetLoad, + ScriptThreadEventCategory::SetViewport => ProfilerCategory::ScriptSetViewport, + ScriptThreadEventCategory::TimerEvent => ProfilerCategory::ScriptTimerEvent, + ScriptThreadEventCategory::WebSocketEvent => ProfilerCategory::ScriptWebSocketEvent, + ScriptThreadEventCategory::WorkerEvent => ProfilerCategory::ScriptWorkerEvent, }; profile(profiler_cat, None, self.time_profiler_chan.clone(), f) } else { @@ -1167,12 +1167,12 @@ impl ScriptTask { let pipeline_id = match source { TimerSource::FromWindow(pipeline_id) => pipeline_id, - TimerSource::FromWorker => panic!("Worker timeouts must not be sent to script task"), + TimerSource::FromWorker => panic!("Worker timeouts must not be sent to script thread"), }; let page = self.root_page(); - let page = page.find(pipeline_id).expect("ScriptTask: received fire timer msg for a - pipeline ID not associated with this script task. This is a bug."); + let page = page.find(pipeline_id).expect("ScriptThread: received fire timer msg for a + pipeline ID not associated with this script thread. This is a bug."); let window = page.window(); window.handle_fire_timer(id); @@ -1301,12 +1301,12 @@ impl ScriptTask { content_process_shutdown_chan, } = new_layout_info; - let layout_pair = ScriptTask::create_layout_channel(None::<&mut ScriptTask>); - let layout_chan = LayoutChan(*ScriptTask::clone_layout_channel( - None::<&mut ScriptTask>, + let layout_pair = ScriptThread::create_layout_channel(None::<&mut ScriptThread>); + let layout_chan = LayoutChan(*ScriptThread::clone_layout_channel( + None::<&mut ScriptThread>, &layout_pair).downcast::>().unwrap()); - let layout_creation_info = NewLayoutTaskInfo { + let layout_creation_info = NewLayoutThreadInfo { id: new_pipeline_id, url: load_data.url.clone(), is_parent: false, @@ -1316,21 +1316,21 @@ impl ScriptTask { failure: failure, paint_chan: paint_chan, script_chan: self.control_chan.clone(), - image_cache_task: self.image_cache_task.clone(), + image_cache_thread: self.image_cache_thread.clone(), layout_shutdown_chan: layout_shutdown_chan, content_process_shutdown_chan: content_process_shutdown_chan, }; let page = self.root_page(); - let parent_page = page.find(containing_pipeline_id).expect("ScriptTask: received a layout + let parent_page = page.find(containing_pipeline_id).expect("ScriptThread: received a layout whose parent has a PipelineId which does not correspond to a pipeline in the script - task's page tree. This is a bug."); + thread's page tree. This is a bug."); let parent_window = parent_page.window(); - // Tell layout to actually spawn the task. + // Tell layout to actually spawn the thread. parent_window.layout_chan() .0 - .send(layout_interface::Msg::CreateLayoutTask(layout_creation_info)) + .send(layout_interface::Msg::CreateLayoutThread(layout_creation_info)) .unwrap(); // Kick off the fetch for the new resource. @@ -1353,7 +1353,7 @@ impl ScriptTask { // https://html.spec.whatwg.org/multipage/#the-end step 7 let addr: Trusted = Trusted::new(doc, self.chan.clone()); let handler = box DocumentProgressHandler::new(addr.clone()); - self.chan.send(CommonScriptMsg::RunnableMsg(ScriptTaskEventCategory::DocumentEvent, handler)).unwrap(); + self.chan.send(CommonScriptMsg::RunnableMsg(ScriptThreadEventCategory::DocumentEvent, handler)).unwrap(); let ConstellationChan(ref chan) = self.constellation_chan; chan.send(ConstellationMsg::LoadComplete(pipeline)).unwrap(); @@ -1433,7 +1433,7 @@ impl ScriptTask { } } let path_seg = format!("url({})", urls.join(", ")); - reports.extend(ScriptTask::get_reports(self.get_cx(), path_seg)); + reports.extend(ScriptThread::get_reports(self.get_cx(), path_seg)); reports_chan.send(reports); } @@ -1532,12 +1532,12 @@ impl ScriptTask { } /// We have gotten a window.close from script, which we pass on to the compositor. - /// We do not shut down the script task now, because the compositor will ask the + /// We do not shut down the script thread now, because the compositor will ask the /// constellation to shut down the pipeline, which will clean everything up /// normally. If we do exit, we will tear down the DOM nodes, possibly at a point /// where layout is still accessing them. fn handle_exit_window_msg(&self, _: PipelineId) { - debug!("script task handling exit window msg"); + debug!("script thread handling exit window msg"); // TODO(tkuehn): currently there is only one window, // so this can afford to be naive and just shut down the @@ -1573,8 +1573,8 @@ impl ScriptTask { document.send_title_to_compositor(); } - /// Handles a request to exit the script task and shut down layout. - /// Returns true if the script task should shut down and false otherwise. + /// Handles a request to exit the script thread and shut down layout. + /// Returns true if the script thread should shut down and false otherwise. fn handle_exit_pipeline_msg(&self, id: PipelineId) -> bool { self.closed_pipelines.borrow_mut().insert(id); @@ -1586,7 +1586,7 @@ impl ScriptTask { if let Some(idx) = idx { let load = self.incomplete_loads.borrow_mut().remove(idx); - // Tell the layout task to begin shutting down, and wait until it + // Tell the layout thread to begin shutting down, and wait until it // processed this message. let (response_chan, response_port) = channel(); let LayoutChan(chan) = load.layout_chan; @@ -1619,7 +1619,7 @@ impl ScriptTask { false } - /// Handles when layout task finishes all animation in one tick + /// Handles when layout thread finishes all animation in one tick fn handle_tick_all_animations(&self, id: PipelineId) { let page = get_page(&self.root_page(), id); let document = page.document(); @@ -1647,7 +1647,7 @@ impl ScriptTask { fn load(&self, metadata: Metadata, incomplete: InProgressLoad) -> ParserRoot { let final_url = metadata.final_url.clone(); { - // send the final url to the layout task. + // send the final url to the layout thread. let LayoutChan(ref chan) = incomplete.layout_chan; chan.send(layout_interface::Msg::SetFinalUrl(final_url.clone())).unwrap(); @@ -1655,7 +1655,7 @@ impl ScriptTask { let ConstellationChan(ref chan) = self.constellation_chan; chan.send(ConstellationMsg::SetFinalUrl(incomplete.pipeline_id, final_url.clone())).unwrap(); } - debug!("ScriptTask: loading {} on page {:?}", incomplete.url.serialize(), incomplete.pipeline_id); + debug!("ScriptThread: loading {} on page {:?}", incomplete.url.serialize(), incomplete.pipeline_id); // We should either be initializing a root page or loading a child page of an // existing one. @@ -1663,12 +1663,12 @@ impl ScriptTask { let frame_element = incomplete.parent_info.and_then(|(parent_id, subpage_id)| { // The root page may not exist yet, if the parent of this frame - // exists in a different script task. + // exists in a different script thread. let borrowed_page = self.page.borrow(); // In the case a parent id exists but the matching page // cannot be found, this means the page exists in a different - // script task (due to origin) so it shouldn't be returned. + // script thread (due to origin) so it shouldn't be returned. // TODO: window.parent will continue to return self in that // case, which is wrong. We should be returning an object that // denies access to most properties (per @@ -1689,7 +1689,7 @@ impl ScriptTask { } else if let Some((parent, _)) = incomplete.parent_info { // We have a new child frame. let parent_page = self.root_page(); - // TODO(gw): This find will fail when we are sharing script tasks + // TODO(gw): This find will fail when we are sharing script threads // between cross origin iframes in the same TLD. let parent_page = parent_page.find(parent) .expect("received load for subpage with missing parent"); @@ -1702,14 +1702,14 @@ impl ScriptTask { } struct AutoPageRemover<'a> { page: PageToRemove, - script_task: &'a ScriptTask, + script_thread: &'a ScriptThread, neutered: bool, } impl<'a> AutoPageRemover<'a> { - fn new(script_task: &'a ScriptTask, page: PageToRemove) -> AutoPageRemover<'a> { + fn new(script_thread: &'a ScriptThread, page: PageToRemove) -> AutoPageRemover<'a> { AutoPageRemover { page: page, - script_task: script_task, + script_thread: script_thread, neutered: false, } } @@ -1722,9 +1722,9 @@ impl ScriptTask { fn drop(&mut self) { if !self.neutered { match self.page { - PageToRemove::Root => *self.script_task.page.borrow_mut() = None, + PageToRemove::Root => *self.script_thread.page.borrow_mut() = None, PageToRemove::Child(id) => { - self.script_task.root_page().remove(id).unwrap(); + self.script_thread.root_page().remove(id).unwrap(); } } } @@ -1738,11 +1738,11 @@ impl ScriptTask { }; let mut page_remover = AutoPageRemover::new(self, page_to_remove); let MainThreadScriptChan(ref sender) = self.chan; - let DOMManipulationTaskSource(ref dom_sender) = self.dom_manipulation_task_source; - let UserInteractionTaskSource(ref user_sender) = self.user_interaction_task_source; - let NetworkingTaskSource(ref network_sender) = self.networking_task_source; - let HistoryTraversalTaskSource(ref history_sender) = self.history_traversal_task_source; - let FileReadingTaskSource(ref file_sender) = self.file_reading_task_source; + let DOMManipulationThreadSource(ref dom_sender) = self.dom_manipulation_thread_source; + let UserInteractionThreadSource(ref user_sender) = self.user_interaction_thread_source; + let NetworkingThreadSource(ref network_sender) = self.networking_thread_source; + let HistoryTraversalThreadSource(ref history_sender) = self.history_traversal_thread_source; + let FileReadingThreadSource(ref file_sender) = self.file_reading_thread_source; let (ipc_timer_event_chan, ipc_timer_event_port) = ipc::channel().unwrap(); ROUTER.route_ipc_receiver_to_mpsc_sender(ipc_timer_event_port, @@ -1752,16 +1752,16 @@ impl ScriptTask { let window = Window::new(self.js_runtime.clone(), page.clone(), MainThreadScriptChan(sender.clone()), - DOMManipulationTaskSource(dom_sender.clone()), - UserInteractionTaskSource(user_sender.clone()), - NetworkingTaskSource(network_sender.clone()), - HistoryTraversalTaskSource(history_sender.clone()), - FileReadingTaskSource(file_sender.clone()), + DOMManipulationThreadSource(dom_sender.clone()), + UserInteractionThreadSource(user_sender.clone()), + NetworkingThreadSource(network_sender.clone()), + HistoryTraversalThreadSource(history_sender.clone()), + FileReadingThreadSource(file_sender.clone()), self.image_cache_channel.clone(), self.compositor.borrow_mut().clone(), - self.image_cache_task.clone(), - self.resource_task.clone(), - self.storage_task.clone(), + self.image_cache_thread.clone(), + self.resource_thread.clone(), + self.storage_thread.clone(), self.mem_profiler_chan.clone(), self.devtools_chan.clone(), self.constellation_chan.clone(), @@ -1788,7 +1788,7 @@ impl ScriptTask { _ => None }; - let loader = DocumentLoader::new_with_task(self.resource_task.clone(), + let loader = DocumentLoader::new_with_thread(self.resource_thread.clone(), Some(page.pipeline()), Some(incomplete.url.clone())); @@ -1903,7 +1903,7 @@ impl ScriptTask { let rect = element.upcast::().get_bounding_content_box(); // In order to align with element edges, we snap to unscaled pixel boundaries, since the - // paint task currently does the same for drawing elements. This is important for pages + // paint thread currently does the same for drawing elements. This is important for pages // that require pixel perfect scroll positioning for proper display (like Acid2). Since we // don't have the device pixel ratio here, this might not be accurate, but should work as // long as the ratio is a whole number. Once #8275 is fixed this should actually take into @@ -2107,7 +2107,7 @@ impl ScriptTask { let subpage = incomplete.parent_info.clone().map(|p| p.1); let script_chan = self.chan.clone(); - let resource_task = self.resource_task.clone(); + let resource_thread = self.resource_thread.clone(); let context = Arc::new(Mutex::new(ParserContext::new(id, subpage, script_chan.clone(), load_data.url.clone()))); @@ -2127,7 +2127,7 @@ impl ScriptTask { load_data.url = url!("about:blank"); } - resource_task.send(ControlMsg::Load(NetLoadData { + resource_thread.send(ControlMsg::Load(NetLoadData { context: LoadContext::Browsing, url: load_data.url, method: load_data.method, @@ -2198,7 +2198,7 @@ impl ScriptTask { } } -impl Drop for ScriptTask { +impl Drop for ScriptThread { fn drop(&mut self) { SCRIPT_TASK_ROOT.with(|root| { *root.borrow_mut() = None; @@ -2211,7 +2211,7 @@ fn shut_down_layout(page_tree: &Rc) { let mut channels = vec!(); for page in page_tree.iter() { - // Tell the layout task to begin shutting down, and wait until it + // Tell the layout thread to begin shutting down, and wait until it // processed this message. let (response_chan, response_port) = channel(); let window = page.window(); @@ -2230,15 +2230,15 @@ fn shut_down_layout(page_tree: &Rc) { page.set_frame(None); } - // Destroy the layout task. If there were node leaks, layout will now crash safely. + // Destroy the layout thread. If there were node leaks, layout will now crash safely. for chan in channels { chan.send(layout_interface::Msg::ExitNow).ok(); } } pub fn get_page(page: &Rc, pipeline_id: PipelineId) -> Rc { - page.find(pipeline_id).expect("ScriptTask: received an event \ - message for a layout channel that is not associated with this script task.\ + page.find(pipeline_id).expect("ScriptThread: received an event \ + message for a layout channel that is not associated with this script thread.\ This is a bug.") } diff --git a/components/script/timers.rs b/components/script/timers.rs index 7e164bbe5eb..786cfbf4c6f 100644 --- a/components/script/timers.rs +++ b/components/script/timers.rs @@ -48,7 +48,7 @@ pub struct ActiveTimers { /// - a timer was added with an earlier callback time. In this case the /// original timer is rescheduled when it is the next one to get called. expected_event_id: Cell, - /// The nesting level of the currently executing timer task or 0. + /// The nesting level of the currently executing timer thread or 0. nesting_level: Cell, } diff --git a/components/script/webdriver_handlers.rs b/components/script/webdriver_handlers.rs index 2ae4931937d..0c9831bf3f6 100644 --- a/components/script/webdriver_handlers.rs +++ b/components/script/webdriver_handlers.rs @@ -29,7 +29,7 @@ use js::jsval::UndefinedValue; use msg::constellation_msg::{PipelineId, WindowSizeData}; use msg::webdriver_msg::{WebDriverFrameId, WebDriverJSError, WebDriverJSResult, WebDriverJSValue}; use page::Page; -use script_task::get_page; +use script_thread::get_page; use std::rc::Rc; use url::Url; use util::str::DOMString; diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs index 3ce9d064b14..a8905de4821 100644 --- a/components/script_traits/lib.rs +++ b/components/script_traits/lib.rs @@ -44,9 +44,9 @@ use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData, SubpageId}; use msg::constellation_msg::{MouseButton, MouseEventType}; use msg::constellation_msg::{MozBrowserEvent, PipelineNamespaceId}; use msg::webdriver_msg::WebDriverScriptCommand; -use net_traits::ResourceTask; -use net_traits::image_cache_task::ImageCacheTask; -use net_traits::storage_task::StorageTask; +use net_traits::ResourceThread; +use net_traits::image_cache_thread::ImageCacheThread; +use net_traits::storage_thread::StorageThread; use profile_traits::mem; use std::any::Any; use util::ipc::OptionalOpaqueIpcSender; @@ -60,10 +60,10 @@ pub use script_msg::{LayoutMsg, ScriptMsg}; pub struct UntrustedNodeAddress(pub *const c_void); unsafe impl Send for UntrustedNodeAddress {} -/// Messages sent to the layout task from the constellation and/or compositor. +/// Messages sent to the layout thread from the constellation and/or compositor. #[derive(Deserialize, Serialize)] pub enum LayoutControlMsg { - /// Requests that this layout task exit. + /// Requests that this layout thread exit. ExitNow, /// Requests the current epoch (layout counter) from this layout. GetCurrentEpoch(IpcSender), @@ -85,12 +85,12 @@ pub struct NewLayoutInfo { pub new_pipeline_id: PipelineId, /// Id of the new frame associated with this pipeline. pub subpage_id: SubpageId, - /// Network request data which will be initiated by the script task. + /// Network request data which will be initiated by the script thread. pub load_data: LoadData, /// The paint channel, cast to `OptionalOpaqueIpcSender`. This is really an /// `Sender`. pub paint_chan: OptionalOpaqueIpcSender, - /// Information on what to do on task failure. + /// Information on what to do on thread failure. pub failure: Failure, /// A port on which layout can receive messages from the pipeline. pub pipeline_port: IpcReceiver, @@ -100,10 +100,10 @@ pub struct NewLayoutInfo { pub content_process_shutdown_chan: IpcSender<()>, } -/// Messages sent from the constellation or layout to the script task. +/// Messages sent from the constellation or layout to the script thread. #[derive(Deserialize, Serialize)] pub enum ConstellationControlMsg { - /// Gives a channel and ID to a layout task, as well as the ID of that layout's parent + /// Gives a channel and ID to a layout thread, as well as the ID of that layout's parent AttachLayout(NewLayoutInfo), /// Window resized. Sends a DOM event eventually, but first we combine events. Resize(PipelineId, WindowSizeData), @@ -115,25 +115,25 @@ pub enum ConstellationControlMsg { SendEvent(PipelineId, CompositorEvent), /// Notifies script of the viewport. Viewport(PipelineId, Rect), - /// Requests that the script task immediately send the constellation the title of a pipeline. + /// Requests that the script thread immediately send the constellation the title of a pipeline. GetTitle(PipelineId), - /// Notifies script task to suspend all its timers + /// Notifies script thread to suspend all its timers Freeze(PipelineId), - /// Notifies script task to resume all its timers + /// Notifies script thread to resume all its timers Thaw(PipelineId), - /// Notifies script task that a url should be loaded in this iframe. + /// Notifies script thread that a url should be loaded in this iframe. Navigate(PipelineId, SubpageId, LoadData), - /// Requests the script task forward a mozbrowser event to an iframe it owns + /// Requests the script thread forward a mozbrowser event to an iframe it owns MozBrowserEvent(PipelineId, SubpageId, MozBrowserEvent), /// Updates the current subpage id of a given iframe UpdateSubpageId(PipelineId, SubpageId, SubpageId), /// Set an iframe to be focused. Used when an element in an iframe gains focus. FocusIFrame(PipelineId, SubpageId), - /// Passes a webdriver command to the script task for execution + /// Passes a webdriver command to the script thread for execution WebDriverScriptCommand(PipelineId, WebDriverScriptCommand), - /// Notifies script task that all animations are done + /// Notifies script thread that all animations are done TickAllAnimations(PipelineId), - /// Notifies the script task that a new Web font has been loaded, and thus the page should be + /// Notifies the script thread that a new Web font has been loaded, and thus the page should be /// reflowed. WebFontLoaded(PipelineId), /// Cause a `load` event to be dispatched at the appropriate frame element. @@ -166,7 +166,7 @@ pub enum TouchEventType { #[derive(Clone, Copy, Debug, Eq, PartialEq, Deserialize, Serialize)] pub struct TouchId(pub i32); -/// Events from the compositor that the script task needs to know about +/// Events from the compositor that the script thread needs to know about #[derive(Deserialize, Serialize)] pub enum CompositorEvent { /// The window was resized. @@ -192,16 +192,16 @@ pub struct TimerEventRequest(pub IpcSender, pub TimerEventId, pub MsDuration); -/// Notifies the script task to fire due timers. -/// TimerSource must be FromWindow when dispatched to ScriptTask and +/// Notifies the script thread to fire due timers. +/// TimerSource must be FromWindow when dispatched to ScriptThread and /// must be FromWorker when dispatched to a DedicatedGlobalWorkerScope #[derive(Deserialize, Serialize)] pub struct TimerEvent(pub TimerSource, pub TimerEventId); -/// Describes the task that requested the TimerEvent. +/// Describes the thread that requested the TimerEvent. #[derive(Copy, Clone, HeapSizeOf, Deserialize, Serialize)] pub enum TimerSource { - /// The event was requested from a window (ScriptTask). + /// The event was requested from a window (ScriptThread). FromWindow(PipelineId), /// The event was requested from a worker (DedicatedGlobalWorkerScope). FromWorker @@ -244,24 +244,24 @@ pub struct InitialScriptState { pub parent_info: Option<(PipelineId, SubpageId)>, /// The compositor. pub compositor: IpcSender, - /// A channel with which messages can be sent to us (the script task). + /// A channel with which messages can be sent to us (the script thread). pub control_chan: IpcSender, /// A port on which messages sent by the constellation to script can be received. pub control_port: IpcReceiver, /// A channel on which messages can be sent to the constellation from script. pub constellation_chan: ConstellationChan, - /// A channel for the layout task to send messages to the constellation. + /// A channel for the layout thread to send messages to the constellation. pub layout_to_constellation_chan: ConstellationChan, /// A channel to schedule timer events. pub scheduler_chan: IpcSender, /// Information that script sends out when it panics. pub failure_info: Failure, - /// A channel to the resource manager task. - pub resource_task: ResourceTask, - /// A channel to the storage task. - pub storage_task: StorageTask, - /// A channel to the image cache task. - pub image_cache_task: ImageCacheTask, + /// A channel to the resource manager thread. + pub resource_thread: ResourceThread, + /// A channel to the storage thread. + pub storage_thread: StorageThread, + /// A channel to the image cache thread. + pub image_cache_thread: ImageCacheThread, /// A channel to the time profiler thread. pub time_profiler_chan: profile_traits::time::ProfilerChan, /// A channel to the memory profiler thread. @@ -276,14 +276,14 @@ pub struct InitialScriptState { pub content_process_shutdown_chan: IpcSender<()>, } -/// Encapsulates external communication with the script task. +/// Encapsulates external communication with the script thread. #[derive(Clone, Deserialize, Serialize)] pub struct ScriptControlChan(pub IpcSender); -/// This trait allows creating a `ScriptTask` without depending on the `script` +/// This trait allows creating a `ScriptThread` without depending on the `script` /// crate. -pub trait ScriptTaskFactory { - /// Create a `ScriptTask`. +pub trait ScriptThreadFactory { + /// Create a `ScriptThread`. fn create(_phantom: Option<&mut Self>, state: InitialScriptState, layout_chan: &OpaqueScriptLayoutChannel, diff --git a/components/script_traits/script_msg.rs b/components/script_traits/script_msg.rs index 869f2428379..d072231eca2 100644 --- a/components/script_traits/script_msg.rs +++ b/components/script_traits/script_msg.rs @@ -20,7 +20,7 @@ use util::cursor::Cursor; pub enum LayoutMsg { /// Indicates whether this pipeline is currently running animations. ChangeRunningAnimationsState(PipelineId, AnimationState), - /// Layout task failure. + /// Layout thread failure. Failure(Failure), /// Requests that the constellation inform the compositor of the a cursor change. SetCursor(Cursor), @@ -35,17 +35,17 @@ pub enum ScriptMsg { ChangeRunningAnimationsState(PipelineId, AnimationState), /// Requests that a new 2D canvas thread be created. (This is done in the constellation because /// 2D canvases may use the GPU and we don't want to give untrusted content access to the GPU.) - CreateCanvasPaintTask(Size2D, IpcSender<(IpcSender, usize)>), + CreateCanvasPaintThread(Size2D, IpcSender<(IpcSender, usize)>), /// Requests that a new WebGL thread be created. (This is done in the constellation because /// WebGL uses the GPU and we don't want to give untrusted content access to the GPU.) - CreateWebGLPaintTask(Size2D, + CreateWebGLPaintThread(Size2D, GLContextAttributes, IpcSender, usize), String>>), /// Dispatched after the DOM load event has fired on a document /// Causes a `load` event to be dispatched to any enclosing frame context element /// for the given pipeline. DOMLoad(PipelineId), - /// Script task failure. + /// Script thread failure. Failure(Failure), /// Notifies the constellation that this frame has received focus. Focus(PipelineId), diff --git a/components/servo/lib.rs b/components/servo/lib.rs index 0f2654aef0f..d63277b129d 100644 --- a/components/servo/lib.rs +++ b/components/servo/lib.rs @@ -11,8 +11,8 @@ //! //! The `Browser` type is responsible for configuring a //! `Constellation`, which does the heavy lifting of coordinating all -//! of Servo's internal subsystems, including the `ScriptTask` and the -//! `LayoutTask`, as well maintains the navigation context. +//! of Servo's internal subsystems, including the `ScriptThread` and the +//! `LayoutThread`, as well maintains the navigation context. //! //! The `Browser` is fed events from a generic type that implements the //! `WindowMethods` trait. @@ -58,20 +58,20 @@ fn webdriver(_port: u16, _constellation: Sender) { } use compositing::CompositorEventListener; use compositing::CompositorMsg as ConstellationMsg; -use compositing::compositor_task::InitialCompositorState; +use compositing::compositor_thread::InitialCompositorState; use compositing::constellation::InitialConstellationState; use compositing::pipeline::UnprivilegedPipelineContent; use compositing::sandboxing; use compositing::windowing::WindowEvent; use compositing::windowing::WindowMethods; -use compositing::{CompositorProxy, CompositorTask, Constellation}; +use compositing::{CompositorProxy, CompositorThread, Constellation}; use gaol::sandbox::{ChildSandbox, ChildSandboxMethods}; -use gfx::font_cache_task::FontCacheTask; +use gfx::font_cache_thread::FontCacheThread; use ipc_channel::ipc::{self, IpcSender}; -use net::image_cache_task::new_image_cache_task; -use net::resource_task::new_resource_task; -use net::storage_task::StorageTaskFactory; -use net_traits::storage_task::StorageTask; +use net::image_cache_thread::new_image_cache_thread; +use net::resource_thread::new_resource_thread; +use net::storage_thread::StorageThreadFactory; +use net_traits::storage_thread::StorageThread; use profile::mem as profile_mem; use profile::time as profile_time; use profile_traits::mem; @@ -163,7 +163,7 @@ impl Browser { // The compositor coordinates with the client window to create the final // rendered page and display it somewhere. - let compositor = CompositorTask::create(window, InitialCompositorState { + let compositor = CompositorThread::create(window, InitialCompositorState { sender: compositor_proxy, receiver: compositor_receiver, constellation_chan: constellation_chan, @@ -199,26 +199,26 @@ fn create_constellation(opts: opts::Opts, mem_profiler_chan: mem::ProfilerChan, devtools_chan: Option>, supports_clipboard: bool) -> Sender { - let resource_task = new_resource_task(opts.user_agent.clone(), devtools_chan.clone()); + let resource_thread = new_resource_thread(opts.user_agent.clone(), devtools_chan.clone()); - let image_cache_task = new_image_cache_task(resource_task.clone()); - let font_cache_task = FontCacheTask::new(resource_task.clone()); - let storage_task: StorageTask = StorageTaskFactory::new(); + let image_cache_thread = new_image_cache_thread(resource_thread.clone()); + let font_cache_thread = FontCacheThread::new(resource_thread.clone()); + let storage_thread: StorageThread = StorageThreadFactory::new(); let initial_state = InitialConstellationState { compositor_proxy: compositor_proxy, devtools_chan: devtools_chan, - image_cache_task: image_cache_task, - font_cache_task: font_cache_task, - resource_task: resource_task, - storage_task: storage_task, + image_cache_thread: image_cache_thread, + font_cache_thread: font_cache_thread, + resource_thread: resource_thread, + storage_thread: storage_thread, time_profiler_chan: time_profiler_chan, mem_profiler_chan: mem_profiler_chan, supports_clipboard: supports_clipboard, }; let constellation_chan = - Constellation::::start(initial_state); + Constellation::::start(initial_state); // Send the URL command to the constellation. match opts.url { @@ -249,7 +249,7 @@ pub fn run_content_process(token: String) { script::init(); - unprivileged_content.start_all::(true); + unprivileged_content.start_all::(true); } diff --git a/components/servo/main.rs b/components/servo/main.rs index 47d275727a2..bd28a9df810 100644 --- a/components/servo/main.rs +++ b/components/servo/main.rs @@ -246,7 +246,7 @@ mod android { use self::libc::fdopen; use self::libc::fgets; use self::libc::{pipe, dup2}; - use servo::util::task::spawn_named; + use servo::util::thread::spawn_named; use std::ffi::CStr; use std::ffi::CString; use std::str::from_utf8; diff --git a/components/style/traversal.rs b/components/style/traversal.rs index c3307aa2593..d20ecbc103c 100644 --- a/components/style/traversal.rs +++ b/components/style/traversal.rs @@ -21,7 +21,7 @@ pub type Generation = u32; /// matches. Thanks to the bloom filter, we can avoid walking up the tree /// looking for ancestors that aren't there in the majority of cases. /// -/// As we walk down the DOM tree a task-local bloom filter is built of all the +/// As we walk down the DOM tree a thread-local bloom filter is built of all the /// CSS `SimpleSelector`s which are part of a `Descendant` compound selector /// (i.e. paired with a `Descendant` combinator, in the `next` field of a /// `CompoundSelector`. @@ -35,15 +35,15 @@ pub type Generation = u32; /// /// Since a work-stealing queue is used for styling, sometimes, the bloom filter /// will no longer be the for the parent of the node we're currently on. When -/// this happens, the task local bloom filter will be thrown away and rebuilt. +/// this happens, the thread local bloom filter will be thrown away and rebuilt. thread_local!( pub static STYLE_BLOOM: RefCell, UnsafeNode, Generation)>> = RefCell::new(None)); -/// Returns the task local bloom filter. +/// Returns the thread local bloom filter. /// /// If one does not exist, a new one will be made for you. If it is out of date, /// it will be cleared and reused. -fn take_task_local_bloom_filter<'ln, N>(parent_node: Option, +fn take_thread_local_bloom_filter<'ln, N>(parent_node: Option, root: OpaqueNode, context: &SharedStyleContext) -> Box @@ -79,12 +79,12 @@ fn take_task_local_bloom_filter<'ln, N>(parent_node: Option, }) } -pub fn put_task_local_bloom_filter(bf: Box, +pub fn put_thread_local_bloom_filter(bf: Box, unsafe_node: &UnsafeNode, context: &SharedStyleContext) { STYLE_BLOOM.with(move |style_bloom| { assert!(style_bloom.borrow().is_none(), - "Putting into a never-taken task-local bloom filter"); + "Putting into a never-taken thread-local bloom filter"); *style_bloom.borrow_mut() = Some((bf, *unsafe_node, context.generation)); }) } @@ -176,7 +176,7 @@ pub fn recalc_style_at<'a, 'ln, N: TNode<'ln>, C: StyleContext<'a>> (context: &' let parent_opt = node.layout_parent_node(root); // Get the style bloom filter. - let mut bf = take_task_local_bloom_filter(parent_opt, root, context.shared_context()); + let mut bf = take_thread_local_bloom_filter(parent_opt, root, context.shared_context()); let nonincremental_layout = opts::get().nonincremental_layout; if nonincremental_layout || node.is_dirty() { @@ -254,6 +254,6 @@ pub fn recalc_style_at<'a, 'ln, N: TNode<'ln>, C: StyleContext<'a>> (context: &' node.insert_into_bloom_filter(&mut *bf); // NB: flow construction updates the bloom filter on the way up. - put_task_local_bloom_filter(bf, &unsafe_layout_node, context.shared_context()); + put_thread_local_bloom_filter(bf, &unsafe_layout_node, context.shared_context()); } diff --git a/components/util/lib.rs b/components/util/lib.rs index 9afbf0d5293..2630d83fbe6 100644 --- a/components/util/lib.rs +++ b/components/util/lib.rs @@ -69,9 +69,9 @@ pub mod print_tree; pub mod range; pub mod resource_files; pub mod str; -pub mod task; -pub mod task_state; -pub mod taskpool; +pub mod thread; +pub mod thread_state; +pub mod threadpool; pub mod tid; pub mod time; pub mod vec; diff --git a/components/util/opts.rs b/components/util/opts.rs index 94f9e148ede..17315ad9766 100644 --- a/components/util/opts.rs +++ b/components/util/opts.rs @@ -119,7 +119,7 @@ pub struct Opts { /// and paint. pub trace_layout: bool, - /// Periodically print out on which events script tasks spend their processing time. + /// Periodically print out on which events script threads spend their processing time. pub profile_script_events: bool, /// Enable all heartbeats for profiling. @@ -224,7 +224,7 @@ pub struct DebugOptions { /// Print notifications when there is a relayout. pub relayout_event: bool, - /// Profile which events script tasks spend their time on. + /// Profile which events script threads spend their time on. pub profile_script_events: bool, /// Enable all heartbeats for profiling. @@ -334,7 +334,7 @@ pub fn print_debug_usage(app: &str) -> ! { print_option("dump-layer-tree", "Print the layer tree whenever it changes."); print_option("relayout-event", "Print notifications when there is a relayout."); print_option("profile-script-events", "Enable profiling of script-related events."); - print_option("profile-heartbeats", "Enable heartbeats for all task categories."); + print_option("profile-heartbeats", "Enable heartbeats for all thread categories."); print_option("show-compositor-borders", "Paint borders along layer and tile boundaries."); print_option("show-fragment-borders", "Paint borders along fragment boundaries."); print_option("show-parallel-paint", "Overlay tiles with colors showing which thread painted them."); @@ -507,7 +507,7 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult { opts.optmulti("", "user-stylesheet", "A user stylesheet to be added to every document", "file.css"); opts.optflag("z", "headless", "Headless mode"); - opts.optflag("f", "hard-fail", "Exit on task failure instead of displaying about:failure"); + opts.optflag("f", "hard-fail", "Exit on thread failure instead of displaying about:failure"); opts.optflagopt("", "devtools", "Start remote devtools server on port", "6000"); opts.optflagopt("", "webdriver", "Start remote WebDriver server on port", "7000"); opts.optopt("", "resolution", "Set window resolution.", "800x600"); diff --git a/components/util/task.rs b/components/util/thread.rs similarity index 90% rename from components/util/task.rs rename to components/util/thread.rs index c9b9463ed29..f17d6985867 100644 --- a/components/util/task.rs +++ b/components/util/thread.rs @@ -8,7 +8,7 @@ use std::borrow::ToOwned; use std::sync::mpsc::Sender; use std::thread; use std::thread::Builder; -use task_state; +use thread_state; pub fn spawn_named(name: String, f: F) where F: FnOnce() + Send + 'static @@ -38,9 +38,9 @@ impl SendOnFailure for IpcSender where T: Send + Serialize + 'static { } } -/// Arrange to send a particular message to a channel if the task fails. +/// Arrange to send a particular message to a channel if the thread fails. pub fn spawn_named_with_send_on_failure(name: String, - state: task_state::TaskState, + state: thread_state::ThreadState, f: F, msg: T, mut dest: S) @@ -48,7 +48,7 @@ pub fn spawn_named_with_send_on_failure(name: String, T: Send + 'static, S: Send + SendOnFailure + 'static { let future_handle = thread::Builder::new().name(name.to_owned()).spawn(move || { - task_state::initialize(state); + thread_state::initialize(state); f() }).unwrap(); diff --git a/components/util/task_state.rs b/components/util/thread_state.rs similarity index 67% rename from components/util/task_state.rs rename to components/util/thread_state.rs index f67e059c4c1..5435e707986 100644 --- a/components/util/task_state.rs +++ b/components/util/thread_state.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -//! Supports dynamic assertions in debug builds about what sort of task is +//! Supports dynamic assertions in debug builds about what sort of thread is //! running and what state it's in. //! //! In release builds, `get` returns 0. All of the other functions inline @@ -11,7 +11,7 @@ pub use self::imp::{enter, exit, get, initialize}; bitflags! { - flags TaskState: u32 { + flags ThreadState: u32 { const SCRIPT = 0x01, const LAYOUT = 0x02, const PAINT = 0x04, @@ -22,8 +22,8 @@ bitflags! { } } -macro_rules! task_types ( ( $( $fun:ident = $flag:ident ; )* ) => ( - impl TaskState { +macro_rules! thread_types ( ( $( $fun:ident = $flag:ident ; )* ) => ( + impl ThreadState { $( #[cfg(debug_assertions)] pub fn $fun(self) -> bool { @@ -37,11 +37,11 @@ macro_rules! task_types ( ( $( $fun:ident = $flag:ident ; )* ) => ( } #[cfg(debug_assertions)] - static TYPES: &'static [TaskState] + static TYPES: &'static [ThreadState] = &[ $( $flag ),* ]; )); -task_types! { +thread_types! { is_script = SCRIPT; is_layout = LAYOUT; is_paint = PAINT; @@ -50,14 +50,14 @@ task_types! { #[cfg(debug_assertions)] mod imp { use std::cell::RefCell; - use super::{TYPES, TaskState}; + use super::{TYPES, ThreadState}; - thread_local!(static STATE: RefCell> = RefCell::new(None)); + thread_local!(static STATE: RefCell> = RefCell::new(None)); - pub fn initialize(x: TaskState) { + pub fn initialize(x: ThreadState) { STATE.with(|ref k| { match *k.borrow() { - Some(s) => panic!("Task state already initialized as {:?}", s), + Some(s) => panic!("Thread state already initialized as {:?}", s), None => () }; *k.borrow_mut() = Some(x); @@ -65,20 +65,20 @@ mod imp { get(); // check the assertion below } - pub fn get() -> TaskState { + pub fn get() -> ThreadState { let state = STATE.with(|ref k| { match *k.borrow() { - None => panic!("Task state not initialized"), + None => panic!("Thread state not initialized"), Some(s) => s, } }); - // Exactly one of the task type flags should be set. + // Exactly one of the thread type flags should be set. assert_eq!(1, TYPES.iter().filter(|&&ty| state.contains(ty)).count()); state } - pub fn enter(x: TaskState) { + pub fn enter(x: ThreadState) { let state = get(); assert!(!state.intersects(x)); STATE.with(|ref k| { @@ -86,7 +86,7 @@ mod imp { }) } - pub fn exit(x: TaskState) { + pub fn exit(x: ThreadState) { let state = get(); assert!(state.contains(x)); STATE.with(|ref k| { @@ -97,9 +97,9 @@ mod imp { #[cfg(not(debug_assertions))] mod imp { - use super::TaskState; - #[inline(always)] pub fn initialize(_: TaskState) { } - #[inline(always)] pub fn get() -> TaskState { TaskState::empty() } - #[inline(always)] pub fn enter(_: TaskState) { } - #[inline(always)] pub fn exit(_: TaskState) { } + use super::ThreadState; + #[inline(always)] pub fn initialize(_: ThreadState) { } + #[inline(always)] pub fn get() -> ThreadState { ThreadState::empty() } + #[inline(always)] pub fn enter(_: ThreadState) { } + #[inline(always)] pub fn exit(_: ThreadState) { } } diff --git a/components/util/taskpool.rs b/components/util/threadpool.rs similarity index 68% rename from components/util/taskpool.rs rename to components/util/threadpool.rs index 501faa6af0f..67bbd08b072 100644 --- a/components/util/taskpool.rs +++ b/components/util/threadpool.rs @@ -2,14 +2,14 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -//! A load-balancing task pool. +//! A load-balancing thread pool. //! -//! This differs in implementation from std::sync::TaskPool in that each job is -//! up for grabs by any of the child tasks in the pool. +//! This differs in implementation from std::sync::ThreadPool in that each job is +//! up for grabs by any of the child threads in the pool. //! // -// This is based on the cargo task pool. +// This is based on the cargo thread pool. // https://github.com/rust-lang/cargo/blob/master/src/cargo/util/pool.rs // // The only difference is that a normal channel is used instead of a sync_channel. @@ -18,27 +18,27 @@ use std::boxed::FnBox; use std::sync::mpsc::{Receiver, Sender, channel}; use std::sync::{Arc, Mutex}; -use task::spawn_named; +use thread::spawn_named; -pub struct TaskPool { +pub struct ThreadPool { tx: Sender>, } -impl TaskPool { - pub fn new(tasks: u32) -> TaskPool { - assert!(tasks > 0); +impl ThreadPool { + pub fn new(threads: u32) -> ThreadPool { + assert!(threads > 0); let (tx, rx) = channel(); let state = Arc::new(Mutex::new(rx)); - for i in 0..tasks { + for i in 0..threads { let state = state.clone(); spawn_named( - format!("TaskPoolWorker {}/{}", i + 1, tasks), + format!("ThreadPoolWorker {}/{}", i + 1, threads), move || worker(&*state)); } - return TaskPool { tx: tx }; + return ThreadPool { tx: tx }; fn worker(rx: &Mutex>>) { while let Ok(job) = rx.lock().unwrap().recv() { diff --git a/components/util/tid.rs b/components/util/tid.rs index 55e3c091bf6..a60c321a984 100644 --- a/components/util/tid.rs +++ b/components/util/tid.rs @@ -10,7 +10,7 @@ static NEXT_TID: AtomicUsize = ATOMIC_USIZE_INIT; thread_local!(static TASK_LOCAL_TID: Rc>> = Rc::new(RefCell::new(None))); -/// Every task gets one, that's unique. +/// Every thread gets one, that's unique. pub fn tid() -> usize { TASK_LOCAL_TID.with(|ref k| { let ret = diff --git a/components/util/workqueue.rs b/components/util/workqueue.rs index dd7c4dd355a..a05879412f3 100644 --- a/components/util/workqueue.rs +++ b/components/util/workqueue.rs @@ -12,8 +12,8 @@ use libc::usleep; use rand::{Rng, XorShiftRng, weak_rng}; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::mpsc::{Receiver, Sender, channel}; -use task::spawn_named; -use task_state; +use thread::spawn_named; +use thread_state; /// A unit of work. /// @@ -234,8 +234,8 @@ pub struct WorkQueue { impl WorkQueue { /// Creates a new work queue and spawns all the threads associated with /// it. - pub fn new(task_name: &'static str, - state: task_state::TaskState, + pub fn new(thread_name: &'static str, + state: thread_state::ThreadState, thread_count: usize) -> WorkQueue { // Set up data structures. let (supervisor_chan, supervisor_port) = channel(); @@ -272,9 +272,9 @@ impl WorkQueue { for (i, thread) in threads.into_iter().enumerate() { spawn_named( - format!("{} worker {}/{}", task_name, i + 1, thread_count), + format!("{} worker {}/{}", thread_name, i + 1, thread_count), move || { - task_state::initialize(state | task_state::IN_WORKER); + thread_state::initialize(state | thread_state::IN_WORKER); let mut thread = thread; thread.start() }) diff --git a/components/webdriver_server/lib.rs b/components/webdriver_server/lib.rs index b462d033148..2979609c295 100644 --- a/components/webdriver_server/lib.rs +++ b/components/webdriver_server/lib.rs @@ -43,7 +43,7 @@ use std::thread; use std::time::Duration; use url::Url; use util::prefs::{get_pref, reset_all_prefs, reset_pref, set_pref, PrefValue}; -use util::task::spawn_named; +use util::thread::spawn_named; use uuid::Uuid; use webdriver::command::{GetParameters, JavascriptCommandParameters, LocatorParameters}; use webdriver::command::{Parameters, SendKeysParameters, SwitchToFrameParameters, TimeoutsParameters}; diff --git a/ports/cef/browser.rs b/ports/cef/browser.rs index 8c722c60f89..3adbe7451a9 100644 --- a/ports/cef/browser.rs +++ b/ports/cef/browser.rs @@ -10,7 +10,7 @@ use interfaces::{cef_browser_t, cef_browser_host_t, cef_client_t, cef_frame_t}; use interfaces::{cef_request_context_t}; use servo::Browser; use types::{cef_browser_settings_t, cef_string_t, cef_window_info_t, cef_window_handle_t}; -use util::task::spawn_named; +use util::thread::spawn_named; use window; use wrappers::CefWrap; @@ -319,4 +319,4 @@ cef_static_method_impls! { let _request_context: CefRequestContext = _request_context; browser_host_create(window_info, client, url, true) }} -} +} \ No newline at end of file diff --git a/ports/cef/interfaces/cef_browser.rs b/ports/cef/interfaces/cef_browser.rs index 50da4741c4d..fb745a2de9b 100644 --- a/ports/cef/interfaces/cef_browser.rs +++ b/ports/cef/interfaces/cef_browser.rs @@ -598,7 +598,7 @@ impl CefBrowser { CefWrap::to_c(message))) } } -} +} impl CefWrap<*mut cef_browser_t> for CefBrowser { fn to_c(rust_object: CefBrowser) -> *mut cef_browser_t { @@ -755,7 +755,7 @@ impl CefRunFileDialogCallback { CefWrap::to_c(file_paths))) } } -} +} impl CefWrap<*mut cef_run_file_dialog_callback_t> for CefRunFileDialogCallback { fn to_c(rust_object: CefRunFileDialogCallback) -> *mut cef_run_file_dialog_callback_t { @@ -914,7 +914,7 @@ impl CefNavigationEntryVisitor { CefWrap::to_c(total))) } } -} +} impl CefWrap<*mut cef_navigation_entry_visitor_t> for CefNavigationEntryVisitor { fn to_c(rust_object: CefNavigationEntryVisitor) -> *mut cef_navigation_entry_visitor_t { @@ -1065,7 +1065,7 @@ impl CefPdfPrintCallback { CefWrap::to_c(ok))) } } -} +} impl CefWrap<*mut cef_pdf_print_callback_t> for CefPdfPrintCallback { fn to_c(rust_object: CefPdfPrintCallback) -> *mut cef_pdf_print_callback_t { @@ -2540,7 +2540,7 @@ impl CefBrowserHost { CefWrap::to_c(request_context))) } } -} +} impl CefWrap<*mut cef_browser_host_t> for CefBrowserHost { fn to_c(rust_object: CefBrowserHost) -> *mut cef_browser_host_t { diff --git a/ports/cef/interfaces/cef_task.rs b/ports/cef/interfaces/cef_task.rs index 762bcf65362..c41d48e93b8 100644 --- a/ports/cef/interfaces/cef_task.rs +++ b/ports/cef/interfaces/cef_task.rs @@ -169,7 +169,7 @@ impl CefTask { self.c_object)) } } -} +} impl CefWrap<*mut cef_task_t> for CefTask { fn to_c(rust_object: CefTask) -> *mut cef_task_t { @@ -449,7 +449,7 @@ impl CefTaskRunner { CefWrap::to_c(threadId))) } } -} +} impl CefWrap<*mut cef_task_runner_t> for CefTaskRunner { fn to_c(rust_object: CefTaskRunner) -> *mut cef_task_runner_t { @@ -475,4 +475,3 @@ impl CefWrap<*mut cef_task_runner_t> for Option { } } } - diff --git a/ports/cef/task.rs b/ports/cef/task.rs index edf04243dd4..c8b03f69f7a 100644 --- a/ports/cef/task.rs +++ b/ports/cef/task.rs @@ -17,4 +17,3 @@ cef_stub_static_method_impls! { fn cef_task_runner_get_for_current_thread() -> *mut cef_task_runner_t fn cef_task_runner_get_for_thread(thread_id: cef_thread_id_t) -> *mut cef_task_runner_t } - diff --git a/ports/cef/window.rs b/ports/cef/window.rs index ced1b80192b..cd9f24ec0fa 100644 --- a/ports/cef/window.rs +++ b/ports/cef/window.rs @@ -18,7 +18,7 @@ use rustc_unicode::str::Utf16Encoder; use types::{cef_cursor_handle_t, cef_cursor_type_t, cef_rect_t}; use wrappers::CefWrap; -use compositing::compositor_task::{self, CompositorProxy, CompositorReceiver}; +use compositing::compositor_thread::{self, CompositorProxy, CompositorReceiver}; use compositing::windowing::{WindowEvent, WindowMethods}; use euclid::point::Point2D; use euclid::scale_factor::ScaleFactor; @@ -509,11 +509,11 @@ impl WindowMethods for Window { } struct CefCompositorProxy { - sender: Sender, + sender: Sender, } impl CompositorProxy for CefCompositorProxy { - fn send(&self, msg: compositor_task::Msg) { + fn send(&self, msg: compositor_thread::Msg) { self.sender.send(msg).unwrap(); app_wakeup(); } diff --git a/ports/glutin/window.rs b/ports/glutin/window.rs index c8e9fa45082..217fd7c5157 100644 --- a/ports/glutin/window.rs +++ b/ports/glutin/window.rs @@ -5,7 +5,7 @@ //! A windowing implementation using glutin. use NestedEventLoopListener; -use compositing::compositor_task::{self, CompositorProxy, CompositorReceiver}; +use compositing::compositor_thread::{self, CompositorProxy, CompositorReceiver}; #[cfg(feature = "window")] use compositing::windowing::{MouseWindowEvent, WindowNavigateMsg}; use compositing::windowing::{WindowEvent, WindowMethods}; @@ -309,10 +309,10 @@ impl Window { // broken way we currently call X11 from multiple threads. // // On some (most?) X11 implementations, blocking here - // with XPeekEvent results in the paint task getting stuck + // with XPeekEvent results in the paint thread getting stuck // in XGetGeometry randomly. When this happens the result // is that until you trigger the XPeekEvent to return - // (by moving the mouse over the window) the paint task + // (by moving the mouse over the window) the paint thread // never completes and you don't see the most recent // results. // @@ -848,7 +848,7 @@ impl WindowMethods for Window { } struct GlutinCompositorProxy { - sender: Sender, + sender: Sender, window_proxy: Option, } @@ -856,7 +856,7 @@ struct GlutinCompositorProxy { unsafe impl Send for GlutinCompositorProxy {} impl CompositorProxy for GlutinCompositorProxy { - fn send(&self, msg: compositor_task::Msg) { + fn send(&self, msg: compositor_thread::Msg) { // Send a message and kick the OS event loop awake. self.sender.send(msg).unwrap(); if let Some(ref window_proxy) = self.window_proxy { diff --git a/ports/gonk/src/window.rs b/ports/gonk/src/window.rs index 23fa8535e9b..5cdf9547929 100644 --- a/ports/gonk/src/window.rs +++ b/ports/gonk/src/window.rs @@ -4,7 +4,7 @@ //! A windowing implementation using gonk interfaces. -use compositing::compositor_task::{self, CompositorProxy, CompositorReceiver}; +use compositing::compositor_thread::{self, CompositorProxy, CompositorReceiver}; use compositing::windowing::{WindowEvent, WindowMethods}; use egl::egl; use egl::egl::EGLConfig; @@ -866,12 +866,12 @@ impl WindowMethods for Window { } struct GonkCompositorProxy { - sender: Sender, + sender: Sender, event_sender: Sender, } impl CompositorProxy for GonkCompositorProxy { - fn send(&self, msg: compositor_task::Msg) { + fn send(&self, msg: compositor_thread::Msg) { // Send a message and kick the OS event loop awake. self.sender.send(msg).ok().unwrap(); self.event_sender.send(WindowEvent::Idle).ok().unwrap(); diff --git a/support/rust-task_info/src/task_basic_info.rs b/support/rust-task_info/src/task_basic_info.rs index d3a9490425e..928f70bef98 100644 --- a/support/rust-task_info/src/task_basic_info.rs +++ b/support/rust-task_info/src/task_basic_info.rs @@ -49,4 +49,3 @@ mod test { assert!(resident_size().unwrap() > 0); } } - diff --git a/tests/unit/gfx/font_cache_task.rs b/tests/unit/gfx/font_cache_thread.rs similarity index 77% rename from tests/unit/gfx/font_cache_task.rs rename to tests/unit/gfx/font_cache_thread.rs index 54cc417acb0..e44b7908b16 100644 --- a/tests/unit/gfx/font_cache_task.rs +++ b/tests/unit/gfx/font_cache_thread.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use gfx::font_cache_task::FontCacheTask; +use gfx::font_cache_thread::FontCacheThread; use ipc_channel::ipc; use style::computed_values::font_family::FontFamily; use style::font_face::Source; @@ -11,11 +11,11 @@ use style::font_face::Source; fn test_local_web_font() { let (inp_chan, _) = ipc::channel().unwrap(); let (out_chan, out_receiver) = ipc::channel().unwrap(); - let font_cache_task = FontCacheTask::new(inp_chan); + let font_cache_thread = FontCacheThread::new(inp_chan); let family_name = FontFamily::FamilyName(From::from("test family")); let variant_name = FontFamily::FamilyName(From::from("test font face")); - font_cache_task.add_web_font(family_name, Source::Local(variant_name), out_chan); + font_cache_thread.add_web_font(family_name, Source::Local(variant_name), out_chan); assert_eq!(out_receiver.recv().unwrap(), ()); } diff --git a/tests/unit/gfx/lib.rs b/tests/unit/gfx/lib.rs index 3bac7b06edc..1521566c5c5 100644 --- a/tests/unit/gfx/lib.rs +++ b/tests/unit/gfx/lib.rs @@ -6,5 +6,5 @@ extern crate gfx; extern crate ipc_channel; extern crate style; -#[cfg(test)] mod font_cache_task; +#[cfg(test)] mod font_cache_thread; #[cfg(test)] mod text_util; diff --git a/tests/unit/net/data_loader.rs b/tests/unit/net/data_loader.rs index 68919732eba..332ac04c997 100644 --- a/tests/unit/net/data_loader.rs +++ b/tests/unit/net/data_loader.rs @@ -18,7 +18,7 @@ fn assert_parse(url: &'static str, data: Option>) { use net::data_loader::load; use net::mime_classifier::MIMEClassifier; - use net::resource_task::CancellationListener; + use net::resource_thread::CancellationListener; use std::sync::Arc; use std::sync::mpsc::channel; use url::Url; diff --git a/tests/unit/net/http_loader.rs b/tests/unit/net/http_loader.rs index 237d4801d7d..b9cee2ea369 100644 --- a/tests/unit/net/http_loader.rs +++ b/tests/unit/net/http_loader.rs @@ -21,7 +21,7 @@ use net::cookie::Cookie; use net::cookie_storage::CookieStorage; use net::hsts::{HSTSList}; use net::http_loader::{load, LoadError, HttpRequestFactory, HttpRequest, HttpResponse}; -use net::resource_task::CancellationListener; +use net::resource_thread::CancellationListener; use net_traits::{LoadData, CookieSource, LoadContext}; use std::borrow::Cow; use std::io::{self, Write, Read, Cursor}; @@ -1197,7 +1197,7 @@ fn test_load_errors_when_viewing_source_and_inner_url_scheme_is_not_http_or_http #[test] fn test_load_errors_when_cancelled() { use ipc_channel::ipc; - use net::resource_task::CancellableResource; + use net::resource_thread::CancellableResource; use net_traits::ResourceId; struct Factory; diff --git a/tests/unit/net/lib.rs b/tests/unit/net/lib.rs index 88cd164e980..7cc340dc3ca 100644 --- a/tests/unit/net/lib.rs +++ b/tests/unit/net/lib.rs @@ -20,6 +20,6 @@ extern crate util; #[cfg(test)] mod cookie; #[cfg(test)] mod data_loader; #[cfg(test)] mod mime_classifier; -#[cfg(test)] mod resource_task; +#[cfg(test)] mod resource_thread; #[cfg(test)] mod hsts; #[cfg(test)] mod http_loader; diff --git a/tests/unit/net/resource_task.rs b/tests/unit/net/resource_thread.rs similarity index 91% rename from tests/unit/net/resource_task.rs rename to tests/unit/net/resource_thread.rs index a33a3b86ed9..2d3d52f589e 100644 --- a/tests/unit/net/resource_task.rs +++ b/tests/unit/net/resource_thread.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use ipc_channel::ipc; -use net::resource_task::new_resource_task; +use net::resource_thread::new_resource_thread; use net_traits::hosts::{parse_hostsfile, host_replacement}; use net_traits::{ControlMsg, LoadData, LoadConsumer, ProgressMsg, LoadContext}; use std::borrow::ToOwned; @@ -13,23 +13,23 @@ use url::Url; #[test] fn test_exit() { - let resource_task = new_resource_task("".to_owned(), None); - resource_task.send(ControlMsg::Exit).unwrap(); + let resource_thread = new_resource_thread("".to_owned(), None); + resource_thread.send(ControlMsg::Exit).unwrap(); } #[test] fn test_bad_scheme() { - let resource_task = new_resource_task("".to_owned(), None); + let resource_thread = new_resource_thread("".to_owned(), None); let (start_chan, start) = ipc::channel().unwrap(); let url = url!("bogus://whatever"); - resource_task.send(ControlMsg::Load(LoadData::new(LoadContext::Browsing, url, None), + resource_thread.send(ControlMsg::Load(LoadData::new(LoadContext::Browsing, url, None), LoadConsumer::Channel(start_chan), None)).unwrap(); let response = start.recv().unwrap(); match response.progress_port.recv().unwrap() { ProgressMsg::Done(result) => { assert!(result.is_err()) } _ => panic!("bleh") } - resource_task.send(ControlMsg::Exit).unwrap(); + resource_thread.send(ControlMsg::Exit).unwrap(); } #[test] @@ -196,20 +196,20 @@ fn test_cancelled_listener() { } }); - let resource_task = new_resource_task("".to_owned(), None); + let resource_thread = new_resource_thread("".to_owned(), None); let (sender, receiver) = ipc::channel().unwrap(); let (id_sender, id_receiver) = ipc::channel().unwrap(); let (sync_sender, sync_receiver) = ipc::channel().unwrap(); let url = Url::parse(&format!("http://127.0.0.1:{}", port)).unwrap(); - resource_task.send(ControlMsg::Load(LoadData::new(LoadContext::Browsing, url, None), + resource_thread.send(ControlMsg::Load(LoadData::new(LoadContext::Browsing, url, None), LoadConsumer::Channel(sender), Some(id_sender))).unwrap(); // get the `ResourceId` and send a cancel message, which should stop the loading loop let res_id = id_receiver.recv().unwrap(); - resource_task.send(ControlMsg::Cancel(res_id)).unwrap(); - // synchronize with the resource_task loop, so that we don't simply send everything at once! - resource_task.send(ControlMsg::Synchronize(sync_sender)).unwrap(); + resource_thread.send(ControlMsg::Cancel(res_id)).unwrap(); + // synchronize with the resource_thread loop, so that we don't simply send everything at once! + resource_thread.send(ControlMsg::Synchronize(sync_sender)).unwrap(); let _ = sync_receiver.recv(); // now, let's send the body, because the connection is still active and data would be loaded // (but, the loading has been cancelled) @@ -219,5 +219,5 @@ fn test_cancelled_listener() { ProgressMsg::Done(result) => assert_eq!(result.unwrap_err(), "load cancelled".to_owned()), _ => panic!("baaaah!"), } - resource_task.send(ControlMsg::Exit).unwrap(); + resource_thread.send(ControlMsg::Exit).unwrap(); } diff --git a/tests/unit/util/lib.rs b/tests/unit/util/lib.rs index 15e37606a14..b42b58ddd7b 100644 --- a/tests/unit/util/lib.rs +++ b/tests/unit/util/lib.rs @@ -14,7 +14,7 @@ extern crate util; #[cfg(test)] mod cache; #[cfg(test)] mod logical_geometry; -#[cfg(test)] mod task; +#[cfg(test)] mod thread; #[cfg(test)] mod vec; #[cfg(test)] mod mem; #[cfg(test)] mod str; diff --git a/tests/unit/util/task.rs b/tests/unit/util/thread.rs similarity index 91% rename from tests/unit/util/task.rs rename to tests/unit/util/thread.rs index 48edf0c7177..e76c39ffd35 100644 --- a/tests/unit/util/task.rs +++ b/tests/unit/util/thread.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use std::borrow::ToOwned; -use util::task::spawn_named; +use util::thread::spawn_named; #[test] fn spawn_named_test() {