mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
task -> thread
This commit is contained in:
parent
f00532bab0
commit
1f02c4ebbb
119 changed files with 1209 additions and 1207 deletions
|
@ -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<ScriptMsg>,
|
||||
/// 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<LayoutMsg>,
|
||||
/// A channel to the associated paint task.
|
||||
/// A channel to the associated paint thread.
|
||||
pub painter_chan: ConstellationChan<PaintMsg>,
|
||||
/// A channel to schedule timer events.
|
||||
pub scheduler_chan: IpcSender<TimerEventRequest>,
|
||||
|
@ -90,14 +90,14 @@ pub struct InitialPipelineState {
|
|||
pub compositor_proxy: Box<CompositorProxy + 'static + Send>,
|
||||
/// A channel to the developer tools, if applicable.
|
||||
pub devtools_chan: Option<Sender<DevtoolsControlMsg>>,
|
||||
/// 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<LTF, STF>(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<TimerEventRequest>,
|
||||
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
|
||||
script_to_compositor_chan: IpcSender<ScriptToCompositorMsg>,
|
||||
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<WindowSizeData>,
|
||||
|
@ -380,10 +380,10 @@ pub struct UnprivilegedPipelineContent {
|
|||
|
||||
impl UnprivilegedPipelineContent {
|
||||
pub fn start_all<LTF, STF>(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<PaintMsg>,
|
||||
compositor_proxy: Box<CompositorProxy + Send + 'static>,
|
||||
script_to_compositor_port: IpcReceiver<ScriptToCompositorMsg>,
|
||||
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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue