Fix error based on retry queue

This commit is contained in:
Emil Fresk 2022-06-21 16:46:33 +02:00
parent 07bd57a20f
commit 4a349653b4
3 changed files with 12 additions and 10 deletions

View file

@ -1,6 +1,5 @@
//! examples/ramfunc.rs //! examples/ramfunc.rs
#![deny(unsafe_code)]
#![deny(warnings)] #![deny(warnings)]
#![no_main] #![no_main]
#![no_std] #![no_std]

View file

@ -137,11 +137,12 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
} }
} }
let n_executors: usize = app let n_executors = app
.software_tasks .software_tasks
.iter() .iter()
.map(|(_, task)| if task.is_async { 1 } else { 0 }) .map(|(_, task)| if task.is_async { 1 } else { 0 })
.sum(); .sum::<usize>()
.max(1);
// TODO: This `retry_queue` comes from the current design of the dispatcher queue handling. // 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 // 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<TokenStream
// `while let Some(...) = (&mut *#rq.get_mut())...` a few lines down. The current "hack" is // `while let Some(...) = (&mut *#rq.get_mut())...` a few lines down. The current "hack" is
// to just requeue the executor run if it should not have been dequeued. This needs however // to just requeue the executor run if it should not have been dequeued. This needs however
// to be done after the ready queue has been exhausted. // to be done after the ready queue has been exhausted.
if n_executors > 0 {
stmts.push(quote!( stmts.push(quote!(
let mut retry_queue: rtic::export::Vec<_, #n_executors> = rtic::export::Vec::new(); let mut retry_queue: rtic::export::Vec<_, #n_executors> = rtic::export::Vec::new();
)); ));
}
stmts.push(quote!( stmts.push(quote!(
while let Some((task, index)) = (&mut *#rq.get_mut()).split().1.dequeue() { while let Some((task, index)) = (&mut *#rq.get_mut()).split().1.dequeue() {

View file

@ -162,7 +162,9 @@ where
let now = mono.now(); let now = mono.now();
if instant <= now { if instant <= now {
// Task became ready, wake the waker // 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 { } else {
// Set compare // Set compare
mono.set_compare(instant); 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 // read of now to the set of the compare, the time can overflow. This is to
// guard against this. // guard against this.
if instant <= now { 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()
}
} }
} }
} }