mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-27 14:04:56 +01:00
Double check the compare instant
This commit is contained in:
parent
dd52539e32
commit
0e134a41b5
1 changed files with 13 additions and 4 deletions
17
src/tq.rs
17
src/tq.rs
|
@ -84,13 +84,22 @@ where
|
||||||
Some(_) => {
|
Some(_) => {
|
||||||
// TODO: Fix this hack...
|
// TODO: Fix this hack...
|
||||||
// Extract the compare time
|
// Extract the compare time
|
||||||
let new_instant = *instant.duration_since_epoch().integer();
|
M::set_compare(*instant.duration_since_epoch().integer());
|
||||||
M::set_compare(new_instant);
|
|
||||||
|
// Double check that the instant we set is really in the future, else
|
||||||
|
// dequeue. If the monotonic is fast enough it can happen that from the
|
||||||
|
// read of now to the set of the compare, the time can overflow. This is to
|
||||||
|
// guard against this.
|
||||||
|
if instant.checked_duration_since(&M::now()).is_none() {
|
||||||
|
let nr = self.0.pop_unchecked();
|
||||||
|
|
||||||
|
Some((nr.task, nr.index))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
// Start counting down from the new reload
|
// Start counting down from the new reload
|
||||||
// mem::transmute::<_, SYST>(()).clear_current();
|
// mem::transmute::<_, SYST>(()).clear_current();
|
||||||
|
|
||||||
None
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue