Fix an embarassing relative/absolute time mismatch in examples.

v0.7.x
whitequark 2017-09-24 13:57:35 +00:00
parent 9c3534e452
commit cfcbcea4eb
3 changed files with 3 additions and 8 deletions

View File

@ -90,6 +90,6 @@ fn main() {
let timestamp = utils::millis_since(startup_time);
let poll_at = iface.poll(&mut sockets, timestamp).expect("poll error");
phy_wait(fd, poll_at).expect("wait error");
phy_wait(fd, poll_at.map(|at| at.saturating_sub(timestamp))).expect("wait error");
}
}

View File

@ -147,12 +147,7 @@ fn main() {
let timestamp = utils::millis_since(startup_time);
let poll_at = iface.poll(&mut sockets, timestamp).expect("poll error");
let mut resume_at = Some(send_at);
if let Some(poll_at) = poll_at {
resume_at = resume_at.map(|at| cmp::min(at, poll_at))
}
debug!("waiting until {:?} ms", resume_at);
let resume_at = [poll_at, Some(send_at)].iter().flat_map(|x| *x).min();
phy_wait(fd, resume_at.map(|at| at.saturating_sub(timestamp))).expect("wait error");
}

View File

@ -182,6 +182,6 @@ fn main() {
let timestamp = utils::millis_since(startup_time);
let poll_at = iface.poll(&mut sockets, timestamp).expect("poll error");
phy_wait(fd, poll_at).expect("wait error");
phy_wait(fd, poll_at.map(|at| at.saturating_sub(timestamp))).expect("wait error");
}
}