diff options
author | 2021-04-08 18:25:09 +0200 | |
---|---|---|
committer | 2021-04-08 19:58:20 +0200 | |
commit | 6aa0fb450f417ce899b43f4539eb226b391a0f2e (patch) | |
tree | 2202c8bb4aa2ba2451f025784a5bad99c4370b2e /macros/src/codegen/software_tasks.rs | |
parent | 43c5ad79c27fbdefa00e2373eba554ec11e1d9df (diff) | |
download | rtic-6aa0fb450f417ce899b43f4539eb226b391a0f2e.tar.gz rtic-6aa0fb450f417ce899b43f4539eb226b391a0f2e.tar.zst rtic-6aa0fb450f417ce899b43f4539eb226b391a0f2e.zip |
Goodbye static mut
Diffstat (limited to 'macros/src/codegen/software_tasks.rs')
-rw-r--r-- | macros/src/codegen/software_tasks.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/macros/src/codegen/software_tasks.rs b/macros/src/codegen/software_tasks.rs index a39fe4cc..e42fb88d 100644 --- a/macros/src/codegen/software_tasks.rs +++ b/macros/src/codegen/software_tasks.rs @@ -52,7 +52,7 @@ pub fn codegen( // /// Queue version of a free-list that keeps track of empty slots in // /// the following buffers #[doc(hidden)] - static mut #fq: #fq_ty = #fq_expr; + static #fq: rtic::RacyCell<#fq_ty> = rtic::RacyCell::new(#fq_expr); )); let elems = &(0..cap) @@ -65,13 +65,15 @@ pub fn codegen( let mono_type = &monotonic.ty; let uninit = mk_uninit(); + // let doc = format!(" RTIC internal: {}:{}", file!(), line!()); mod_app.push(quote!( #uninit // /// Buffer that holds the instants associated to the inputs of a task + // #[doc = #doc] #[doc(hidden)] - static mut #instants: - [core::mem::MaybeUninit<rtic::time::Instant<#mono_type>>; #cap_lit] = - [#(#elems,)*]; + static #instants: + rtic::RacyCell<[core::mem::MaybeUninit<rtic::time::Instant<#mono_type>>; #cap_lit]> = + rtic::RacyCell::new([#(#elems,)*]); )); } @@ -82,8 +84,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` |