mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Add task profiler, which works by instrumenting each task runtime when enabled.
This commit is contained in:
parent
3aad350a64
commit
90d793cdc8
7 changed files with 241 additions and 10 deletions
|
@ -7,17 +7,21 @@ use std::task;
|
|||
use std::comm::Sender;
|
||||
use std::task::TaskBuilder;
|
||||
use native::task::NativeTaskBuilder;
|
||||
|
||||
use rtinstrument;
|
||||
use task_state;
|
||||
|
||||
pub fn spawn_named<S: IntoMaybeOwned<'static>>(name: S, f: proc():Send) {
|
||||
let builder = task::TaskBuilder::new().named(name);
|
||||
builder.spawn(f);
|
||||
builder.spawn(proc() {
|
||||
rtinstrument::instrument(f);
|
||||
});
|
||||
}
|
||||
|
||||
pub fn spawn_named_native<S: IntoMaybeOwned<'static>>(name: S, f: proc():Send) {
|
||||
let builder = task::TaskBuilder::new().named(name).native();
|
||||
builder.spawn(f);
|
||||
builder.spawn(proc() {
|
||||
rtinstrument::instrument(f);
|
||||
});
|
||||
}
|
||||
|
||||
/// Arrange to send a particular message to a channel if the task fails.
|
||||
|
@ -29,7 +33,7 @@ pub fn spawn_named_with_send_on_failure<T: Send>(name: &'static str,
|
|||
native: bool) {
|
||||
let with_state = proc() {
|
||||
task_state::initialize(state);
|
||||
f()
|
||||
rtinstrument::instrument(f);
|
||||
};
|
||||
|
||||
let future_result = if native {
|
||||
|
@ -41,12 +45,14 @@ pub fn spawn_named_with_send_on_failure<T: Send>(name: &'static str,
|
|||
let watched_name = name.to_string();
|
||||
let watcher_name = format!("{:s}Watcher", watched_name);
|
||||
TaskBuilder::new().named(watcher_name).spawn(proc() {
|
||||
match future_result.unwrap() {
|
||||
Ok(()) => (),
|
||||
Err(..) => {
|
||||
debug!("{:s} failed, notifying constellation", name);
|
||||
dest.send(msg);
|
||||
rtinstrument::instrument(proc() {
|
||||
match future_result.unwrap() {
|
||||
Ok(()) => (),
|
||||
Err(..) => {
|
||||
debug!("{:s} failed, notifying constellation", name);
|
||||
dest.send(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue