This commit is contained in:
Milo Turner 2020-03-14 15:51:49 -04:00
parent c37b767cb9
commit f6cddca534
1 changed files with 9 additions and 24 deletions

View File

@ -225,11 +225,6 @@ where
Timer, Timer,
} }
enum Action {
Continue,
Quit,
}
let mut src = SegmentSource::new(inp); let mut src = SegmentSource::new(inp);
let in_flight = 66; let in_flight = 66;
@ -252,31 +247,22 @@ where
} }
); );
let act = match evt { match evt {
Evt::Timer => { Evt::Timer => {
let delay_ms = (1000 / in_flight) as u64; let delay_ms = (1000 / in_flight) as u64;
deadline += Duration::from_millis(delay_ms); deadline += Duration::from_millis(delay_ms);
match src.get_segment().await { if let Some((seg_idx, payload)) = src.get_segment().await {
Some((seg_idx, payload)) => { log.send_data(seg_idx as usize, payload.len()).await;
log.send_data(seg_idx as usize, payload.len()).await; to_send.push(UpMsg::Data {
to_send.push(UpMsg::Data { seg_idx,
seg_idx, payload: payload.clone(),
payload: payload.clone(), });
});
Action::Continue
}
None => Action::Quit,
} }
} }
Evt::Recv(DownMsg::Ack { idxs }) => { Evt::Recv(DownMsg::Ack { idxs }) => {
log.debug_msg(format!("got {} acks", idxs.len())).await; log.debug_msg(format!("got {} acks", idxs.len())).await;
src.ack(&idxs); src.ack(&idxs);
if src.is_file_completed() {
Action::Quit
} else {
Action::Continue
}
} }
}; };
@ -288,9 +274,8 @@ where
} }
} }
match act { if src.is_file_completed() {
Action::Continue => (), break
Action::Quit => break,
} }
} }