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

View file

@ -65,13 +65,14 @@ 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(hidden)]
static mut #instants:
[core::mem::MaybeUninit<rtic::time::Instant<#mono_type>>; #cap_lit] =
[#(#elems,)*];
#[doc = #doc]
static #instants:
rtic::RacyCell<[core::mem::MaybeUninit<rtic::time::Instant<#mono_type>>; #cap_lit]> =
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 tq_ty = quote!(rtic::export::TimerQueue<#mono_type, #t, #n>);
let doc = format!(" RTIC internal: {}:{}", file!(), line!());
items.push(quote!(
#[doc(hidden)]
static mut #tq: #tq_ty = rtic::export::TimerQueue(
rtic::export::BinaryHeap(
rtic::export::iBinaryHeap::new()
)
);
#[doc = #doc]
static #tq: rtic::RacyCell<#tq_ty> =
rtic::RacyCell::new(rtic::export::TimerQueue(
rtic::export::BinaryHeap(rtic::export::iBinaryHeap::new())
));
));
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(|_|
if let Some(mono) = #app_path::#m_ident.as_mut() {
#tq.dequeue(|| #disable_isr, mono)
#tq.get_mut_unchecked().dequeue(|| #disable_isr, mono)
} else {
// We can only use the timer queue if `init` has returned, and it
// writes the `Some(monotonic)` we are accessing here.