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