diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-07-09 11:00:11 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-09 11:00:11 +0000 |
| commit | e1a4d001f8e724596cd9de3e90698ce7de473b3f (patch) | |
| tree | f7aac5eae4cc2e19cc06bfd6fa8dab843dcfb276 /examples/cfg-whole-task.rs | |
| parent | 13dc3992e616d817e38c167c4b47db816855f18b (diff) | |
| parent | f3d9fd9b638a25b497e1ca02e7ce5de86c9fc1c9 (diff) | |
Merge #494
494: Resoures take 2 r=korken89 a=korken89
Co-authored-by: Emil Fresk <emil.fresk@gmail.com>
Diffstat (limited to 'examples/cfg-whole-task.rs')
| -rw-r--r-- | examples/cfg-whole-task.rs | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/examples/cfg-whole-task.rs b/examples/cfg-whole-task.rs index 47c3530..3fbdb2d 100644 --- a/examples/cfg-whole-task.rs +++ b/examples/cfg-whole-task.rs @@ -13,22 +13,32 @@ mod app { #[cfg(debug_assertions)] use cortex_m_semihosting::hprintln; - #[resources] - struct Resources { + #[shared] + struct Shared { #[cfg(debug_assertions)] // <- `true` when using the `dev` profile - #[init(0)] count: u32, #[cfg(never)] - #[init(0)] unused: u32, } + #[local] + struct Local {} + #[init] - fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { + fn init(_: init::Context) -> (Shared, Local, init::Monotonics) { foo::spawn().unwrap(); foo::spawn().unwrap(); - (init::LateResources {}, init::Monotonics()) + ( + Shared { + #[cfg(debug_assertions)] + count: 0, + #[cfg(never)] + unused: 1, + }, + Local {}, + init::Monotonics(), + ) } #[idle] @@ -40,17 +50,17 @@ mod app { } } - #[task(capacity = 2, resources = [count])] + #[task(capacity = 2, shared = [count])] fn foo(mut _cx: foo::Context) { #[cfg(debug_assertions)] { - _cx.resources.count.lock(|count| *count += 1); + _cx.shared.count.lock(|count| *count += 1); - log::spawn(_cx.resources.count.lock(|count| *count)).unwrap(); + log::spawn(_cx.shared.count.lock(|count| *count)).unwrap(); } // this wouldn't compile in `release` mode - // *_cx.resources.count += 1; + // *_cx.shared.count += 1; // .. } @@ -58,17 +68,17 @@ mod app { // The whole task should disappear, // currently still present in the Tasks enum #[cfg(never)] - #[task(capacity = 2, resources = [count])] + #[task(capacity = 2, shared = [count])] fn foo2(mut _cx: foo2::Context) { #[cfg(debug_assertions)] { - _cx.resources.count.lock(|count| *count += 10); + _cx.shared.count.lock(|count| *count += 10); - log::spawn(_cx.resources.count.lock(|count| *count)).unwrap(); + log::spawn(_cx.shared.count.lock(|count| *count)).unwrap(); } // this wouldn't compile in `release` mode - // *_cx.resources.count += 1; + // *_cx.shared.count += 1; // .. } |
