From c70191c01956c6a37e7d3b4318c79b6fc6c9309f Mon Sep 17 00:00:00 2001 From: Per Lindgren Date: Thu, 11 Mar 2021 01:48:33 +0100 Subject: [PATCH] RacyCell inputs --- macros/src/codegen/dispatchers.rs | 6 +++++- macros/src/codegen/module.rs | 1 + macros/src/codegen/software_tasks.rs | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/macros/src/codegen/dispatchers.rs b/macros/src/codegen/dispatchers.rs index d928fe2a86..ebf928830c 100644 --- a/macros/src/codegen/dispatchers.rs +++ b/macros/src/codegen/dispatchers.rs @@ -86,7 +86,11 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec { let #tupled = - #inputs.get_unchecked(usize::from(index)).as_ptr().read(); + #inputs + .get_mut_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( diff --git a/macros/src/codegen/module.rs b/macros/src/codegen/module.rs index 1b2c893ffe..195106d836 100644 --- a/macros/src/codegen/module.rs +++ b/macros/src/codegen/module.rs @@ -210,6 +210,7 @@ pub fn codegen( unsafe { if let Some(index) = rtic::export::interrupt::free(|_| #app_path::#fq.get_mut_unchecked().dequeue()) { #app_path::#inputs + .get_mut_unchecked() .get_unchecked_mut(usize::from(index)) .as_mut_ptr() .write(input); diff --git a/macros/src/codegen/software_tasks.rs b/macros/src/codegen/software_tasks.rs index 2bfe6adb38..b114f79dca 100644 --- a/macros/src/codegen/software_tasks.rs +++ b/macros/src/codegen/software_tasks.rs @@ -82,8 +82,8 @@ pub fn codegen( #uninit // /// Buffer that holds the inputs of a task #[doc(hidden)] - static mut #inputs_ident: [core::mem::MaybeUninit<#input_ty>; #cap_lit] = - [#(#elems,)*]; + static #inputs_ident: rtic::RacyCell<[core::mem::MaybeUninit<#input_ty>; #cap_lit]> = + rtic::RacyCell::new([#(#elems,)*]); )); // `${task}Resources`