mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Supress panics for ProfilerChan sends.
This commit is contained in:
parent
89c46369a2
commit
25a237c466
6 changed files with 15 additions and 4 deletions
|
@ -16,6 +16,7 @@ energy-profiling = ["energymon", "energy-monitor"]
|
|||
ipc-channel = "0.5"
|
||||
energymon = {git = "https://github.com/energymon/energymon-rust.git", optional = true}
|
||||
energy-monitor = {version = "0.2.0", optional = true}
|
||||
log = "0.3.5"
|
||||
plugins = {path = "../plugins"}
|
||||
serde = "0.8"
|
||||
serde_derive = "0.8"
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
#![deny(unsafe_code)]
|
||||
|
||||
extern crate ipc_channel;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate serde;
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
|
|
|
@ -19,7 +19,9 @@ pub trait OpaqueSender<T> {
|
|||
|
||||
impl<T> OpaqueSender<T> for Sender<T> {
|
||||
fn send(&self, message: T) {
|
||||
let _ = Sender::send(self, message);
|
||||
if let Err(e) = Sender::send(self, message) {
|
||||
warn!("Error communicating with the target thread from the profiler: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,9 +33,11 @@ pub struct ProfilerChan(pub IpcSender<ProfilerMsg>);
|
|||
impl ProfilerChan {
|
||||
/// Send `msg` on this `IpcSender`.
|
||||
///
|
||||
/// Panics if the send fails.
|
||||
/// Warns if the send fails.
|
||||
pub fn send(&self, msg: ProfilerMsg) {
|
||||
self.0.send(msg).unwrap();
|
||||
if let Err(e) = self.0.send(msg) {
|
||||
warn!("Error communicating with the memory profiler thread: {}", e);
|
||||
}
|
||||
}
|
||||
|
||||
/// Runs `f()` with memory profiling.
|
||||
|
|
|
@ -22,7 +22,9 @@ pub struct ProfilerChan(pub IpcSender<ProfilerMsg>);
|
|||
|
||||
impl ProfilerChan {
|
||||
pub fn send(&self, msg: ProfilerMsg) {
|
||||
let _ = self.0.send(msg);
|
||||
if let Err(e) = self.0.send(msg) {
|
||||
warn!("Error communicating with the time profiler thread: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
1
components/servo/Cargo.lock
generated
1
components/servo/Cargo.lock
generated
|
@ -1972,6 +1972,7 @@ dependencies = [
|
|||
"energy-monitor 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"energymon 0.2.0 (git+https://github.com/energymon/energymon-rust.git)",
|
||||
"ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"plugins 0.0.1",
|
||||
"serde 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
1
ports/cef/Cargo.lock
generated
1
ports/cef/Cargo.lock
generated
|
@ -1798,6 +1798,7 @@ name = "profile_traits"
|
|||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"plugins 0.0.1",
|
||||
"serde 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue