diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-10-23 20:52:58 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-23 20:52:58 +0000 |
| commit | bbcae14e37c5f4ab5701b2a688bee52bfa7aaa1b (patch) | |
| tree | c70a80e9bcacb54838f09141bd1d2b27e844760f /examples/lock.rs | |
| parent | b3aa9e99a975eca637582f31de20fe11ae8f7d64 (diff) | |
| parent | e8eca4be37a2fe1af25b203ace5e99b31fcc3972 (diff) | |
Merge #399
399: Now all locks are symmetric r=AfoHT a=korken89
Co-authored-by: Emil Fresk <emil.fresk@gmail.com>
Diffstat (limited to 'examples/lock.rs')
| -rw-r--r-- | examples/lock.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/examples/lock.rs b/examples/lock.rs index c4930a2..2fbf760 100644 --- a/examples/lock.rs +++ b/examples/lock.rs @@ -52,11 +52,15 @@ mod app { } #[task(binds = GPIOB, priority = 2, resources = [shared])] - fn gpiob(c: gpiob::Context) { - // the higher priority task does *not* need a critical section - *c.resources.shared += 1; + fn gpiob(mut c: gpiob::Context) { + // the higher priority task does still need a critical section + let shared = c.resources.shared.lock(|shared| { + *shared += 1; + + *shared + }); - hprintln!("D - shared = {}", *c.resources.shared).unwrap(); + hprintln!("D - shared = {}", shared).unwrap(); } #[task(binds = GPIOC, priority = 3)] |
