Parallelize deserialize

This commit is contained in:
Greg Fitzgerald 2018-04-06 15:52:58 -06:00
parent 6fd32fe850
commit 6869089111
1 changed files with 8 additions and 12 deletions

View File

@ -139,18 +139,14 @@ impl<W: Write + Send + 'static> AccountantSkel<W> {
} }
pub fn deserialize_packets(p: &packet::Packets) -> Vec<Option<(Request, SocketAddr)>> { pub fn deserialize_packets(p: &packet::Packets) -> Vec<Option<(Request, SocketAddr)>> {
// TODO: deserealize in parallel p.packets
let mut r = vec![]; .par_iter()
for x in &p.packets { .map(|x| {
let rsp_addr = x.meta.addr(); deserialize(&x.data[0..x.meta.size])
let sz = x.meta.size; .map(|req| (req, x.meta.addr()))
if let Ok(req) = deserialize(&x.data[0..sz]) { .ok()
r.push(Some((req, rsp_addr))); })
} else { .collect()
r.push(None);
}
}
r
} }
fn process( fn process(