aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/util/time.rs
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2014-01-23 13:43:03 -0800
committerPatrick Walton <pcwalton@mimiga.net>2014-01-24 20:50:30 -0800
commit18a2050a64cd6f320cc59cb490a69b0e895f11d3 (patch)
tree0a27b979054bded5489300728f0ebcb6f5e4ed8d /src/components/util/time.rs
parent86c29d253a6ffada3488cb08d0154d8901ec252e (diff)
downloadservo-18a2050a64cd6f320cc59cb490a69b0e895f11d3.tar.gz
servo-18a2050a64cd6f320cc59cb490a69b0e895f11d3.zip
layout: Port parallel layout over to a generic "work queue"
infrastructure. The work queue accepts abstract generic "work units", which in this case are layout operations. The same speedups have been observed.
Diffstat (limited to 'src/components/util/time.rs')
-rw-r--r--src/components/util/time.rs23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/components/util/time.rs b/src/components/util/time.rs
index b4ac13ef095..426cfad705a 100644
--- a/src/components/util/time.rs
+++ b/src/components/util/time.rs
@@ -37,10 +37,12 @@ impl ProfilerChan {
}
pub enum ProfilerMsg {
- // Normal message used for reporting time
+ /// Normal message used for reporting time
TimeMsg(ProfilerCategory, f64),
- // Message used to force print the profiling metrics
+ /// Message used to force print the profiling metrics
PrintMsg,
+ /// Tells the profiler to shut down.
+ ExitMsg,
}
#[deriving(Eq, Clone, TotalEq, TotalOrd)]
@@ -136,7 +138,12 @@ impl Profiler {
None => {
// no-op to handle profiler messages when the profiler is inactive
spawn_named("Profiler", proc() {
- while port.recv_opt().is_some() {}
+ loop {
+ match port.recv_opt() {
+ None | Some(ExitMsg) => break,
+ _ => {}
+ }
+ }
});
}
}
@@ -156,13 +163,17 @@ impl Profiler {
loop {
let msg = self.port.recv_opt();
match msg {
- Some (msg) => self.handle_msg(msg),
+ Some(msg) => {
+ if !self.handle_msg(msg) {
+ break
+ }
+ }
None => break
}
}
}
- fn handle_msg(&mut self, msg: ProfilerMsg) {
+ fn handle_msg(&mut self, msg: ProfilerMsg) -> bool {
match msg {
TimeMsg(category, t) => self.buckets.find_mut(&category).unwrap().push(t),
PrintMsg => match self.last_msg {
@@ -170,8 +181,10 @@ impl Profiler {
Some(TimeMsg(..)) => self.print_buckets(),
_ => ()
},
+ ExitMsg => return false,
};
self.last_msg = Some(msg);
+ true
}
fn print_buckets(&mut self) {