mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Removed panic channel, replaced by integrated logging and issue reporting.
This commit is contained in:
parent
b34b30fd96
commit
c889900cff
22 changed files with 85 additions and 251 deletions
|
@ -2,12 +2,6 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#[cfg(feature = "servo")] use backtrace::Backtrace;
|
||||
#[cfg(feature = "servo")] use ipc_channel::ipc::IpcSender;
|
||||
#[cfg(feature = "servo")] use panicking;
|
||||
#[cfg(feature = "servo")] use serde::Serialize;
|
||||
#[cfg(feature = "servo")] use std::any::Any;
|
||||
#[cfg(feature = "servo")] use thread_state;
|
||||
use std::thread;
|
||||
|
||||
pub fn spawn_named<F>(name: String, f: F)
|
||||
|
@ -15,39 +9,3 @@ pub fn spawn_named<F>(name: String, f: F)
|
|||
{
|
||||
thread::Builder::new().name(name).spawn(f).expect("Thread spawn failed");
|
||||
}
|
||||
|
||||
/// Arrange to send a particular message to a channel if the thread fails.
|
||||
#[cfg(feature = "servo")]
|
||||
pub fn spawn_named_with_send_on_panic<F, Id>(name: String,
|
||||
state: thread_state::ThreadState,
|
||||
f: F,
|
||||
id: Id,
|
||||
panic_chan: IpcSender<(Id, String, String)>)
|
||||
where F: FnOnce() + Send + 'static,
|
||||
Id: Copy + Send + Serialize + 'static,
|
||||
{
|
||||
thread::Builder::new().name(name).spawn(move || {
|
||||
thread_state::initialize(state);
|
||||
panicking::set_thread_local_hook(Box::new(move |payload: &Any| {
|
||||
debug!("Thread failed, notifying constellation");
|
||||
let reason = payload.downcast_ref::<String>().map(|s| String::from(&**s))
|
||||
.or(payload.downcast_ref::<&'static str>().map(|s| String::from(*s)))
|
||||
.unwrap_or_else(|| String::from("<unknown reason>"));
|
||||
// FIXME(ajeffrey): Really we should send the backtrace itself,
|
||||
// not just a string representation. Unfortunately we can't, because
|
||||
// Servo won't compile backtrace with the serialize-serde feature:
|
||||
//
|
||||
// .../quasi_macros-0.9.0/src/lib.rs:19:29: 19:32 error: mismatched types:
|
||||
// expected `&mut syntex::Registry`,
|
||||
// found `&mut rustc_plugin::Registry<'_>`
|
||||
// (expected struct `syntex::Registry`,
|
||||
// found struct `rustc_plugin::Registry`) [E0308]
|
||||
// .../quasi_macros-0.9.0/src/lib.rs:19 quasi_codegen::register(reg);
|
||||
//
|
||||
// so for the moment we just send a debug string.
|
||||
let backtrace = format!("{:?}", Backtrace::new());
|
||||
let _ = panic_chan.send((id, reason, backtrace));
|
||||
}));
|
||||
f()
|
||||
}).expect("Thread spawn failed");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue