Goodbye static mut

This commit is contained in:
Emil Fresk 2021-04-08 18:25:09 +02:00
parent 43c5ad79c2
commit 6aa0fb450f
11 changed files with 145 additions and 59 deletions

View file

@ -59,7 +59,7 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea
// );
items.push(quote!(
#[doc(hidden)]
static mut #rq: #rq_ty = #rq_expr;
static #rq: rtic::RacyCell<#rq_ty> = rtic::RacyCell::new(#rq_expr);
));
let arms = channel
@ -86,8 +86,12 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea
#(#cfgs)*
#t::#name => {
let #tupled =
#inputs.get_unchecked(usize::from(index)).as_ptr().read();
#fq.split().0.enqueue_unchecked(index);
#inputs
.get_unchecked()
.get_unchecked(usize::from(index))
.as_ptr()
.read();
#fq.get_mut_unchecked().split().0.enqueue_unchecked(index);
let priority = &rtic::export::Priority::new(PRIORITY);
#app_path::#name(
#locals_new
@ -100,7 +104,7 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea
.collect::<Vec<_>>();
stmts.push(quote!(
while let Some((task, index)) = #rq.split().1.dequeue() {
while let Some((task, index)) = #rq.get_mut_unchecked().split().1.dequeue() {
match task {
#(#arms)*
}