From 4a349653b41da12c686f17ced7f4227245415ff1 Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Tue, 21 Jun 2022 16:46:33 +0200 Subject: [PATCH] Fix error based on retry queue --- examples/ramfunc.rs | 1 - macros/src/codegen/dispatchers.rs | 13 ++++++------- src/tq.rs | 8 ++++++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/examples/ramfunc.rs b/examples/ramfunc.rs index 54acd7e84c..b3b8012c38 100644 --- a/examples/ramfunc.rs +++ b/examples/ramfunc.rs @@ -1,6 +1,5 @@ //! examples/ramfunc.rs -#![deny(unsafe_code)] #![deny(warnings)] #![no_main] #![no_std] diff --git a/macros/src/codegen/dispatchers.rs b/macros/src/codegen/dispatchers.rs index ea3c31f38b..9552451c75 100644 --- a/macros/src/codegen/dispatchers.rs +++ b/macros/src/codegen/dispatchers.rs @@ -137,11 +137,12 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec() + .max(1); // TODO: This `retry_queue` comes from the current design of the dispatcher queue handling. // To remove this we would need to redesign how the dispatcher handles queues, and this can @@ -152,11 +153,9 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec 0 { - stmts.push(quote!( - let mut retry_queue: rtic::export::Vec<_, #n_executors> = rtic::export::Vec::new(); - )); - } + stmts.push(quote!( + let mut retry_queue: rtic::export::Vec<_, #n_executors> = rtic::export::Vec::new(); + )); stmts.push(quote!( while let Some((task, index)) = (&mut *#rq.get_mut()).split().1.dequeue() { diff --git a/src/tq.rs b/src/tq.rs index ed4016eced..0c7ac8ff4a 100644 --- a/src/tq.rs +++ b/src/tq.rs @@ -162,7 +162,9 @@ where let now = mono.now(); if instant <= now { // Task became ready, wake the waker - self.waker_queue.pop().map(|v| v.val.waker.wake_by_ref()); + if let Some(v) = self.waker_queue.pop() { + v.val.waker.wake_by_ref() + } } else { // Set compare mono.set_compare(instant); @@ -172,7 +174,9 @@ where // read of now to the set of the compare, the time can overflow. This is to // guard against this. if instant <= now { - self.waker_queue.pop().map(|v| v.val.waker.wake_by_ref()); + if let Some(v) = self.waker_queue.pop() { + v.val.waker.wake_by_ref() + } } } }