Un-stub timer code

This commit is contained in:
Keegan McAllister 2013-08-12 18:17:13 -07:00
parent a2d9810b69
commit fb3db6a72d
3 changed files with 26 additions and 26 deletions

View file

@ -26,6 +26,8 @@ use std::comm::{Chan, SharedChan, Port};
use std::num::Orderable;
use std::task;
use std::vec;
use std::rt::rtio::RtioTimer;
use std::rt::io::timer::Timer;
use geom::matrix::identity;
use geom::point::Point2D;
use geom::size::Size2D;
@ -480,6 +482,7 @@ impl CompositorTask {
};
// Enter the main event loop.
let tm = Timer::new().unwrap();
while !done {
// Check for new messages coming from the rendering task.
check_for_messages(&self.port);
@ -492,10 +495,7 @@ impl CompositorTask {
composite();
}
/*
timer::sleep(&uv_global_loop::get(), 10);
*/
fail!("stubbed out!");
tm.sleep(10);
// If a pinch-zoom happened recently, ask for tiles at the new resolution
if zoom_action && precise_time_s() - zoom_time > 0.3 {

View file

@ -49,6 +49,8 @@ pub use gfx::text;
pub use servo_util::url::make_url;
use std::comm;
use std::os;
use std::rt::rtio::RtioTimer;
use std::rt::io::timer::Timer;
#[path="compositing/mod.rs"]
pub mod compositing;
@ -104,20 +106,17 @@ fn run(opts: &Opts) {
let (profiler_port, profiler_chan) = comm::stream();
let profiler_chan = ProfilerChan::new(profiler_chan);
Profiler::create(profiler_port);
/*
do opts.profiler_period.map |period| {
do opts.profiler_period.map |&period| {
let profiler_chan = profiler_chan.clone();
let period = *period;
let period = (period * 1000f) as u64;
do spawn {
let tm = Timer::new().unwrap();
loop {
extra::timer::sleep(&uv_global_loop::get(),
(period * 1000f) as uint);
tm.sleep(period);
profiler_chan.send(PrintMsg);
}
}
};
*/
fail!("stubbed out!");
// Create the compositor.
let (compositor_port, compositor_chan) = comm::stream();

View file

@ -18,9 +18,12 @@ use js::{JSVAL_NULL, JSPROP_ENUMERATE};
use std::cast;
use std::comm;
use std::comm::Chan;
use std::comm::SharedChan;
use std::io;
use std::ptr;
use std::int;
use std::rt::rtio::RtioTimer;
use std::rt::io::timer::Timer;
use js::jsapi::JSVal;
pub enum TimerControlMsg {
@ -35,7 +38,7 @@ pub struct Window {
script_chan: ScriptChan,
compositor: @ScriptListener,
wrapper: WrapperCache,
timer_chan: Chan<TimerControlMsg>,
timer_chan: SharedChan<TimerControlMsg>,
}
#[unsafe_destructor]
@ -139,21 +142,19 @@ impl BindingObject for Window {
impl Window {
pub fn SetTimeout(&self, _cx: *JSContext, callback: JSVal, timeout: i32) -> i32 {
/*
let timeout = int::max(0, timeout) as uint;
let timeout = int::max(0, timeout) as u64;
// Post a delayed message to the per-window timer task; it will dispatch it
// to the relevant script handler that will deal with it.
let data = ~TimerData {
funval: callback,
args: ~[]
};
timer::delayed_send(&uv_global_loop::get(),
timeout,
&self.timer_chan,
TimerMessage_Fire(data));
*/
fail!("stubbed out!");
let tm = Timer::new().unwrap();
let chan = self.timer_chan.clone();
do spawn {
tm.sleep(timeout);
chan.send(TimerMessage_Fire(~TimerData {
funval: callback,
args: ~[]
}));
}
return 0; //TODO return handle into list of active timers
}
@ -182,7 +183,7 @@ impl Window {
}
}
}
timer_chan
SharedChan::new(timer_chan)
},
};