mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-25 21:19:35 +01:00
generate resource proxies only when needed
only `static mut` resources need proxies
This commit is contained in:
parent
bc024f1979
commit
36073a6342
1 changed files with 33 additions and 30 deletions
|
@ -234,40 +234,43 @@ fn resources(
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(Ownership::Shared { ceiling }) = analysis.ownerships.get(name) {
|
// generate a resource proxy when needed
|
||||||
let ptr = if res.expr.is_none() {
|
if res.mutability.is_some() {
|
||||||
quote!(#name.as_mut_ptr())
|
if let Some(Ownership::Shared { ceiling }) = analysis.ownerships.get(name) {
|
||||||
} else {
|
let ptr = if res.expr.is_none() {
|
||||||
quote!(&mut #name)
|
quote!(#name.as_mut_ptr())
|
||||||
};
|
} else {
|
||||||
|
quote!(&mut #name)
|
||||||
|
};
|
||||||
|
|
||||||
mod_resources.push(quote!(
|
mod_resources.push(quote!(
|
||||||
pub struct #name<'a> {
|
pub struct #name<'a> {
|
||||||
priority: &'a Priority,
|
priority: &'a Priority,
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> #name<'a> {
|
|
||||||
#[inline(always)]
|
|
||||||
pub unsafe fn new(priority: &'a Priority) -> Self {
|
|
||||||
#name { priority }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
impl<'a> #name<'a> {
|
||||||
pub unsafe fn priority(&self) -> &Priority {
|
#[inline(always)]
|
||||||
self.priority
|
pub unsafe fn new(priority: &'a Priority) -> Self {
|
||||||
}
|
#name { priority }
|
||||||
}
|
}
|
||||||
));
|
|
||||||
|
|
||||||
const_app.push(impl_mutex(
|
#[inline(always)]
|
||||||
app,
|
pub unsafe fn priority(&self) -> &Priority {
|
||||||
cfgs,
|
self.priority
|
||||||
true,
|
}
|
||||||
name,
|
}
|
||||||
quote!(#ty),
|
));
|
||||||
*ceiling,
|
|
||||||
ptr,
|
const_app.push(impl_mutex(
|
||||||
));
|
app,
|
||||||
|
cfgs,
|
||||||
|
true,
|
||||||
|
name,
|
||||||
|
quote!(#ty),
|
||||||
|
*ceiling,
|
||||||
|
ptr,
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue