doc comments to source file + timer queue using RacyCell

This commit is contained in:
Per Lindgren 2021-03-11 14:27:07 +01:00
parent bd4cc1b9f0
commit d7f79bf3ce
3 changed files with 17 additions and 12 deletions

View file

@ -266,6 +266,9 @@ pub fn codegen(
let user_imports = &app.user_imports; let user_imports = &app.user_imports;
let doc = format!(" RTIC internal: {}:{}", file!(), line!());
items.push(quote!(#[doc = #doc]));
items.push(quote!( items.push(quote!(
/// Holds methods related to this monotonic /// Holds methods related to this monotonic
pub mod #m { pub mod #m {
@ -312,6 +315,7 @@ pub fn codegen(
.write(input); .write(input);
#app_path::#instants #app_path::#instants
.get_mut_unchecked()
.get_unchecked_mut(usize::from(index)) .get_unchecked_mut(usize::from(index))
.as_mut_ptr() .as_mut_ptr()
.write(instant); .write(instant);
@ -324,7 +328,7 @@ pub fn codegen(
rtic::export::interrupt::free(|_| rtic::export::interrupt::free(|_|
if let Some(mono) = #app_path::#m_ident.as_mut() { if let Some(mono) = #app_path::#m_ident.as_mut() {
#app_path::#tq.enqueue_unchecked( #app_path::#tq.get_mut_unchecked().enqueue_unchecked(
nr, nr,
|| #enable_interrupt, || #enable_interrupt,
|| #pend, || #pend,

View file

@ -65,13 +65,14 @@ pub fn codegen(
let mono_type = &monotonic.ty; let mono_type = &monotonic.ty;
let uninit = mk_uninit(); let uninit = mk_uninit();
let doc = format!(" RTIC internal: {}:{}", file!(), line!());
mod_app.push(quote!( mod_app.push(quote!(
#uninit #uninit
// /// Buffer that holds the instants associated to the inputs of a task // /// Buffer that holds the instants associated to the inputs of a task
#[doc(hidden)] #[doc = #doc]
static mut #instants: static #instants:
[core::mem::MaybeUninit<rtic::time::Instant<#mono_type>>; #cap_lit] = rtic::RacyCell<[core::mem::MaybeUninit<rtic::time::Instant<#mono_type>>; #cap_lit]> =
[#(#elems,)*]; rtic::RacyCell::new([#(#elems,)*]);
)); ));
} }

View file

@ -61,13 +61,13 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea
let n = util::capacity_typenum(cap, false); let n = util::capacity_typenum(cap, false);
let tq_ty = quote!(rtic::export::TimerQueue<#mono_type, #t, #n>); let tq_ty = quote!(rtic::export::TimerQueue<#mono_type, #t, #n>);
let doc = format!(" RTIC internal: {}:{}", file!(), line!());
items.push(quote!( items.push(quote!(
#[doc(hidden)] #[doc = #doc]
static mut #tq: #tq_ty = rtic::export::TimerQueue( static #tq: rtic::RacyCell<#tq_ty> =
rtic::export::BinaryHeap( rtic::RacyCell::new(rtic::export::TimerQueue(
rtic::export::iBinaryHeap::new() rtic::export::BinaryHeap(rtic::export::iBinaryHeap::new())
) ));
);
)); ));
let mono = util::monotonic_ident(&monotonic_name); let mono = util::monotonic_ident(&monotonic_name);
@ -129,7 +129,7 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea
while let Some((task, index)) = rtic::export::interrupt::free(|_| while let Some((task, index)) = rtic::export::interrupt::free(|_|
if let Some(mono) = #app_path::#m_ident.as_mut() { if let Some(mono) = #app_path::#m_ident.as_mut() {
#tq.dequeue(|| #disable_isr, mono) #tq.get_mut_unchecked().dequeue(|| #disable_isr, mono)
} else { } else {
// We can only use the timer queue if `init` has returned, and it // We can only use the timer queue if `init` has returned, and it
// writes the `Some(monotonic)` we are accessing here. // writes the `Some(monotonic)` we are accessing here.