Parallelize deserialize
This commit is contained in:
parent
6fd32fe850
commit
6869089111
|
@ -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(
|
||||||
|
|
Loading…
Reference in New Issue