This commit is contained in:
Per Lindgren 2020-06-12 22:39:20 +02:00
parent cfd5f4785e
commit 3c208003f5
4 changed files with 322 additions and 2 deletions

View file

@ -83,6 +83,7 @@ pub fn codegen(
#cfg_core
pub struct #name<'a> {
priority: &'a Priority,
locked: Cell<bool>,
}
#(#cfgs)*
@ -90,13 +91,25 @@ pub fn codegen(
impl<'a> #name<'a> {
#[inline(always)]
pub unsafe fn new(priority: &'a Priority) -> Self {
#name { priority }
#name {
priority,
locked: Cell::new(false),
}
}
#[inline(always)]
pub unsafe fn priority(&self) -> &Priority {
self.priority
}
#[inline(always)]
pub unsafe fn is_locked(&self) -> bool {
self.locked.get()
}
pub unsafe fn lock(&self) {
self.locked.set(true);
}
}
));
@ -130,7 +143,7 @@ pub fn codegen(
} else {
quote!(mod resources {
use rtic::export::Priority;
use core::cell::Cell;
#(#mod_resources)*
})
};