Supress panics for ProfilerChan sends.

This commit is contained in:
Josh Matthews 2016-11-10 09:11:59 -05:00
parent 89c46369a2
commit 25a237c466
6 changed files with 15 additions and 4 deletions

View file

@ -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"

View file

@ -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;

View file

@ -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.

View file

@ -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);
}
}
}