mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-30 15:34:33 +01:00
Restart executor on finish if there are retries
This commit is contained in:
parent
b2ec1fa651
commit
952bb5c431
2 changed files with 20 additions and 11 deletions
|
@ -164,12 +164,6 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
|
||||||
#(#arms)*
|
#(#arms)*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while let Some((task, index)) = retry_queue.pop() {
|
|
||||||
rtic::export::interrupt::free(|_| {
|
|
||||||
(&mut *#rq.get_mut()).enqueue_unchecked((task, index));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
));
|
));
|
||||||
|
|
||||||
for (name, _task) in app.software_tasks.iter().filter_map(|(name, task)| {
|
for (name, _task) in app.software_tasks.iter().filter_map(|(name, task)| {
|
||||||
|
@ -185,14 +179,26 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
|
||||||
stmts.push(quote!(
|
stmts.push(quote!(
|
||||||
if #executor_run_ident.load(core::sync::atomic::Ordering::Relaxed) {
|
if #executor_run_ident.load(core::sync::atomic::Ordering::Relaxed) {
|
||||||
#executor_run_ident.store(false, core::sync::atomic::Ordering::Relaxed);
|
#executor_run_ident.store(false, core::sync::atomic::Ordering::Relaxed);
|
||||||
(&mut *#exec_name.get_mut()).poll(|| {
|
if (&mut *#exec_name.get_mut()).poll(|| {
|
||||||
#executor_run_ident.store(true, core::sync::atomic::Ordering::Release);
|
#executor_run_ident.store(true, core::sync::atomic::Ordering::Release);
|
||||||
rtic::pend(#device::#enum_::#interrupt);
|
rtic::pend(#device::#enum_::#interrupt);
|
||||||
});
|
}) && !retry_queue.is_empty() {
|
||||||
|
// If the retry queue is not empty and the executor finished, restart this
|
||||||
|
// dispatch to check if the executor should be restarted.
|
||||||
|
rtic::pend(#device::#enum_::#interrupt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stmts.push(quote!(
|
||||||
|
while let Some((task, index)) = retry_queue.pop() {
|
||||||
|
rtic::export::interrupt::free(|_| {
|
||||||
|
(&mut *#rq.get_mut()).enqueue_unchecked((task, index));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
));
|
||||||
|
|
||||||
let doc = format!("Interrupt handler to dispatch tasks at priority {}", level);
|
let doc = format!("Interrupt handler to dispatch tasks at priority {}", level);
|
||||||
let attribute = &interrupts[&level].1.attrs;
|
let attribute = &interrupts[&level].1.attrs;
|
||||||
items.push(quote!(
|
items.push(quote!(
|
||||||
|
|
|
@ -65,7 +65,7 @@ pub mod executor {
|
||||||
self.task = Some(future);
|
self.task = Some(future);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn poll(&mut self, wake: fn()) {
|
pub fn poll(&mut self, wake: fn()) -> bool {
|
||||||
if let Some(future) = &mut self.task {
|
if let Some(future) = &mut self.task {
|
||||||
unsafe {
|
unsafe {
|
||||||
let waker = Waker::from_raw(RawWaker::new(wake as *const (), &WAKER_VTABLE));
|
let waker = Waker::from_raw(RawWaker::new(wake as *const (), &WAKER_VTABLE));
|
||||||
|
@ -75,11 +75,14 @@ pub mod executor {
|
||||||
match future.poll(&mut cx) {
|
match future.poll(&mut cx) {
|
||||||
Poll::Ready(_) => {
|
Poll::Ready(_) => {
|
||||||
self.task = None;
|
self.task = None;
|
||||||
|
true // Only true if we finished now
|
||||||
}
|
}
|
||||||
Poll::Pending => {}
|
Poll::Pending => false,
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue