diff options
author | 2020-10-22 21:36:32 +0200 | |
---|---|---|
committer | 2020-10-23 08:38:18 +0200 | |
commit | e8eca4be37a2fe1af25b203ace5e99b31fcc3972 (patch) | |
tree | c70a80e9bcacb54838f09141bd1d2b27e844760f /examples/resource.rs | |
parent | b3aa9e99a975eca637582f31de20fe11ae8f7d64 (diff) | |
download | rtic-e8eca4be37a2fe1af25b203ace5e99b31fcc3972.tar.gz rtic-e8eca4be37a2fe1af25b203ace5e99b31fcc3972.tar.zst rtic-e8eca4be37a2fe1af25b203ace5e99b31fcc3972.zip |
Now all locks are symmetric
Test fixes
Fix test
Fix comment
Diffstat (limited to 'examples/resource.rs')
-rw-r--r-- | examples/resource.rs | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/examples/resource.rs b/examples/resource.rs index 87ba3367..d86d46fb 100644 --- a/examples/resource.rs +++ b/examples/resource.rs @@ -42,18 +42,23 @@ mod app { // `shared` can be accessed from this context #[task(binds = UART0, resources = [shared])] - fn uart0(cx: uart0::Context) { - let shared: &mut u32 = cx.resources.shared; - *shared += 1; + fn uart0(mut cx: uart0::Context) { + let shared = cx.resources.shared.lock(|shared| { + *shared += 1; + *shared + }); hprintln!("UART0: shared = {}", shared).unwrap(); } // `shared` can be accessed from this context #[task(binds = UART1, resources = [shared])] - fn uart1(cx: uart1::Context) { - *cx.resources.shared += 1; + fn uart1(mut cx: uart1::Context) { + let shared = cx.resources.shared.lock(|shared| { + *shared += 1; + *shared + }); - hprintln!("UART1: shared = {}", cx.resources.shared).unwrap(); + hprintln!("UART1: shared = {}", shared).unwrap(); } } |