format components/profile_traits

This commit is contained in:
Anshul Malik 2018-09-10 09:56:01 +05:30
parent 6cb39fad47
commit ce9231c471
5 changed files with 96 additions and 57 deletions

View file

@ -10,12 +10,18 @@ use time;
use time::ProfilerCategory;
use time::ProfilerChan;
pub struct IpcReceiver<T> where T: for<'de> Deserialize<'de> + Serialize {
pub struct IpcReceiver<T>
where
T: for<'de> Deserialize<'de> + Serialize,
{
ipc_receiver: ipc::IpcReceiver<T>,
time_profile_chan: ProfilerChan,
}
impl<T> IpcReceiver<T> where T: for<'de> Deserialize<'de> + Serialize {
impl<T> IpcReceiver<T>
where
T: for<'de> Deserialize<'de> + Serialize,
{
pub fn recv(&self) -> Result<T, bincode::Error> {
time::profile(
ProfilerCategory::IpcReceiver,
@ -34,8 +40,12 @@ impl<T> IpcReceiver<T> where T: for<'de> Deserialize<'de> + Serialize {
}
}
pub fn channel<T>(time_profile_chan: ProfilerChan) -> Result<(ipc::IpcSender<T>, IpcReceiver<T>), Error>
where T: for<'de> Deserialize<'de> + Serialize, {
pub fn channel<T>(
time_profile_chan: ProfilerChan,
) -> Result<(ipc::IpcSender<T>, IpcReceiver<T>), Error>
where
T: for<'de> Deserialize<'de> + Serialize,
{
let (ipc_sender, ipc_receiver) = ipc::channel()?;
let profiled_ipc_receiver = IpcReceiver {
ipc_receiver,