diff options
author | 2020-06-12 22:39:20 +0200 | |
---|---|---|
committer | 2020-06-12 22:39:20 +0200 | |
commit | 3c208003f564c7f256435d1b3845bd1269a8f506 (patch) | |
tree | 16dd6503e4b63eb293d449ee5afdbb5ae49dd8ed /macros/src/codegen/resources.rs | |
parent | cfd5f4785e9c2ae88e666d1fb94a3488904a87f5 (diff) | |
download | rtic-3c208003f564c7f256435d1b3845bd1269a8f506.tar.gz rtic-3c208003f564c7f256435d1b3845bd1269a8f506.tar.zst rtic-3c208003f564c7f256435d1b3845bd1269a8f506.zip |
wip1
Diffstat (limited to 'macros/src/codegen/resources.rs')
-rw-r--r-- | macros/src/codegen/resources.rs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/macros/src/codegen/resources.rs b/macros/src/codegen/resources.rs index 0bec3e5a..6788648b 100644 --- a/macros/src/codegen/resources.rs +++ b/macros/src/codegen/resources.rs @@ -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)* }) }; |