aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Emil Fresk <emil.fresk@gmail.com> 2021-09-27 15:29:42 +0200
committerGravatar Emil Fresk <emil.fresk@gmail.com> 2021-09-27 15:39:05 +0200
commitcdab00a0c63dc8fa6a69877799af665564170b9b (patch)
tree624102165b055833322c8ca12ab8a54a56cc958d
parent8940c50fa739f47045ce45b23422645bf4922538 (diff)
downloadrtic-cdab00a0c63dc8fa6a69877799af665564170b9b.tar.gz
rtic-cdab00a0c63dc8fa6a69877799af665564170b9b.tar.zst
rtic-cdab00a0c63dc8fa6a69877799af665564170b9b.zip
Fix a bug in the timer queue due to comparison bug in embedded-time
-rw-r--r--src/tq.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/tq.rs b/src/tq.rs
index dcaccc9e..44f8dd4c 100644
--- a/src/tq.rs
+++ b/src/tq.rs
@@ -111,7 +111,9 @@ where
mono.clear_compare_flag();
if let Some(instant) = self.0.peek().map(|p| p.instant) {
- if instant <= unwrapper(Clock::try_now(mono)) {
+ let now = unwrapper(Clock::try_now(mono));
+ // This if statement is like this and not <= due to a bug in embedded-time
+ if instant < now || instant == now {
// task became ready
let nr = unsafe { self.0.pop_unchecked() };
@@ -124,7 +126,8 @@ where
// 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 <= unwrapper(Clock::try_now(mono)) {
+ let now = unwrapper(Clock::try_now(mono));
+ if instant < now || instant == now {
let nr = unsafe { self.0.pop_unchecked() };
Some((nr.task, nr.index))