use spawn_with in lieu of cells

This commit is contained in:
Tim Kuehn 2013-09-19 16:47:01 -04:00
parent 7ffcc29d54
commit 6c28b5cc9c
2 changed files with 26 additions and 40 deletions

View file

@ -4,10 +4,9 @@
use compositing::{CompositorChan, SetIds, SetLayerClipRect}; use compositing::{CompositorChan, SetIds, SetLayerClipRect};
use std::cell::Cell;
use std::comm; use std::comm;
use std::comm::Port; use std::comm::Port;
use std::task; use std::task::spawn_with;
use geom::size::Size2D; use geom::size::Size2D;
use geom::rect::Rect; use geom::rect::Rect;
use gfx::opts::Opts; use gfx::opts::Opts;
@ -258,32 +257,25 @@ impl Constellation {
profiler_chan: ProfilerChan) profiler_chan: ProfilerChan)
-> ConstellationChan { -> ConstellationChan {
let opts = Cell::new((*opts).clone());
let (constellation_port, constellation_chan) = special_stream!(ConstellationChan); let (constellation_port, constellation_chan) = special_stream!(ConstellationChan);
let constellation_port = Cell::new(constellation_port); do spawn_with((constellation_port, constellation_chan.clone(),
compositor_chan, resource_task, image_cache_task,
let compositor_chan = Cell::new(compositor_chan); profiler_chan, opts.clone()))
let constellation_chan_clone = Cell::new(constellation_chan.clone()); |(constellation_port, constellation_chan, compositor_chan, resource_task,
image_cache_task, profiler_chan, opts)| {
let resource_task = Cell::new(resource_task);
let image_cache_task = Cell::new(image_cache_task);
let profiler_chan = Cell::new(profiler_chan);
do task::spawn {
let mut constellation = Constellation { let mut constellation = Constellation {
chan: constellation_chan_clone.take(), chan: constellation_chan,
request_port: constellation_port.take(), request_port: constellation_port,
compositor_chan: compositor_chan.take(), compositor_chan: compositor_chan,
resource_task: resource_task.take(), resource_task: resource_task,
image_cache_task: image_cache_task.take(), image_cache_task: image_cache_task,
pipelines: HashMap::new(), pipelines: HashMap::new(),
navigation_context: NavigationContext::new(), navigation_context: NavigationContext::new(),
next_pipeline_id: PipelineId(0), next_pipeline_id: PipelineId(0),
pending_frames: ~[], pending_frames: ~[],
pending_sizes: HashMap::new(), pending_sizes: HashMap::new(),
profiler_chan: profiler_chan.take(), profiler_chan: profiler_chan,
opts: opts.take(), opts: opts
}; };
constellation.run(); constellation.run();
} }
@ -730,9 +722,7 @@ impl Constellation {
None => { None => {
// Add to_add to parent's children, if it is not the root // Add to_add to parent's children, if it is not the root
let parent = &to_add.parent; let parent = &to_add.parent;
let to_add = Cell::new(to_add);
for parent in parent.iter() { for parent in parent.iter() {
let to_add = to_add.take();
let subpage_id = to_add.pipeline.subpage_id.expect("Constellation: let subpage_id = to_add.pipeline.subpage_id.expect("Constellation:
Child frame's subpage id is None. This should be impossible."); Child frame's subpage id is None. This should be impossible.");
let rect = self.pending_sizes.pop(&(parent.id, subpage_id)); let rect = self.pending_sizes.pop(&(parent.id, subpage_id));

View file

@ -25,12 +25,11 @@ use servo_msg::constellation_msg::{PipelineId, SubpageId, RendererReadyMsg};
use servo_msg::constellation_msg::{LoadIframeUrlMsg, IFrameSandboxed, IFrameUnsandboxed}; use servo_msg::constellation_msg::{LoadIframeUrlMsg, IFrameSandboxed, IFrameUnsandboxed};
use servo_msg::constellation_msg; use servo_msg::constellation_msg;
use std::cell::Cell;
use std::comm; use std::comm;
use std::comm::{Port, SharedChan}; use std::comm::{Port, SharedChan};
use std::io::read_whole_file; use std::io::read_whole_file;
use std::ptr; use std::ptr;
use std::task::{SingleThreaded, task}; use std::task::spawn_with;
use std::util::replace; use std::util::replace;
use dom::window::TimerData; use dom::window::TimerData;
use geom::size::Size2D; use geom::size::Size2D;
@ -435,22 +434,19 @@ impl ScriptTask {
resource_task: ResourceTask, resource_task: ResourceTask,
image_cache_task: ImageCacheTask, image_cache_task: ImageCacheTask,
initial_size: Future<Size2D<uint>>) { initial_size: Future<Size2D<uint>>) {
let compositor = Cell::new(compositor); do spawn_with((compositor, layout_chan, port, chan, constellation_chan,
let port = Cell::new(port); resource_task, image_cache_task, initial_size))
let initial_size = Cell::new(initial_size); |(compositor, layout_chan, port, chan, constellation_chan,
// FIXME: rust#6399 resource_task, image_cache_task, initial_size)| {
let mut the_task = task();
the_task.sched_mode(SingleThreaded);
do spawn {
let script_task = ScriptTask::new(id, let script_task = ScriptTask::new(id,
@compositor.take() as @ScriptListener, @compositor as @ScriptListener,
layout_chan.clone(), layout_chan,
port.take(), port,
chan.clone(), chan,
constellation_chan.clone(), constellation_chan,
resource_task.clone(), resource_task,
image_cache_task.clone(), image_cache_task,
initial_size.take()); initial_size);
script_task.start(); script_task.start();
} }
} }