Skip to content

Allow naming lock type of shared resources #612

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ For each category, *Added*, *Changed*, *Fixed* add new entries at the top!
- `examples/periodic-at2.rs`, an example of a periodic process with two tasks, with offset timing.
Here we depict two alternative usages of the timer type, explicit and trait based.
- book: Update `Monotonic` tips.
- rename lock types `{}_lock` (instead of `{}_that_needs_to_be_locked`)
- change visibility of `app::shared_resources` module to pub

### Fixed

Expand Down
4 changes: 2 additions & 2 deletions macros/src/codegen/shared_resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub fn codegen(
// For future use
// let doc = format!(" RTIC internal: {}:{}", file!(), line!());

let shared_name = util::need_to_lock_ident(name);
let shared_name = util::lock_ident(name);

if !res.properties.lock_free {
mod_resources.push(quote!(
Expand Down Expand Up @@ -104,7 +104,7 @@ pub fn codegen(
let mod_resources = if mod_resources.is_empty() {
quote!()
} else {
quote!(mod shared_resources {
quote!(pub mod shared_resources {
use rtic::export::Priority;

#(#mod_resources)*
Expand Down
2 changes: 1 addition & 1 deletion macros/src/codegen/shared_resources_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub fn codegen(ctxt: Context, needs_lt: &mut bool, app: &App) -> (TokenStream2,
};
let ty = &res.ty;
let mangled_name = util::static_shared_resource_ident(name);
let shared_name = util::need_to_lock_ident(name);
let shared_name = util::lock_ident(name);

if res.properties.lock_free {
// Lock free resources of `idle` and `init` get 'static lifetime
Expand Down
4 changes: 2 additions & 2 deletions macros/src/codegen/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ pub fn declared_static_local_resource_ident(name: &Ident, task_name: &Ident) ->
mark_internal_name(&format!("local_{}_{}", task_name, name))
}

pub fn need_to_lock_ident(name: &Ident) -> Ident {
Ident::new(&format!("{}_that_needs_to_be_locked", name), name.span())
pub fn lock_ident(name: &Ident) -> Ident {
Ident::new(&format!("{}_lock", name), name.span())
}

/// The name to get better RT flag errors
Expand Down