diff options
author | 2019-07-10 22:42:44 +0200 | |
---|---|---|
committer | 2019-07-10 22:42:44 +0200 | |
commit | 9195038c87703fc94b6e99f6de593886d51c2b19 (patch) | |
tree | 56855952357fe5bb689504ed8a6348dc3c1f3718 /examples/not-send.rs | |
parent | 14d63f496118f4243f28ddf3218523aa36a80322 (diff) | |
download | rtic-9195038c87703fc94b6e99f6de593886d51c2b19.tar.gz rtic-9195038c87703fc94b6e99f6de593886d51c2b19.tar.zst rtic-9195038c87703fc94b6e99f6de593886d51c2b19.zip |
implement RFC #212
Diffstat (limited to 'examples/not-send.rs')
-rw-r--r-- | examples/not-send.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/examples/not-send.rs b/examples/not-send.rs index f240e511..d27cc82f 100644 --- a/examples/not-send.rs +++ b/examples/not-send.rs @@ -17,7 +17,10 @@ pub struct NotSend { #[app(device = lm3s6965)] const APP: () = { - static mut SHARED: Option<NotSend> = None; + struct Resources { + #[init(None)] + shared: Option<NotSend>, + } #[init(spawn = [baz, quux])] fn init(c: init::Context) { @@ -36,16 +39,16 @@ const APP: () = { // scenario 1 } - #[task(priority = 2, resources = [SHARED])] + #[task(priority = 2, resources = [shared])] fn baz(c: baz::Context) { // scenario 2: resource shared between tasks that run at the same priority - *c.resources.SHARED = Some(NotSend { _0: PhantomData }); + *c.resources.shared = Some(NotSend { _0: PhantomData }); } - #[task(priority = 2, resources = [SHARED])] + #[task(priority = 2, resources = [shared])] fn quux(c: quux::Context) { // scenario 2 - let _not_send = c.resources.SHARED.take().unwrap(); + let _not_send = c.resources.shared.take().unwrap(); debug::exit(debug::EXIT_SUCCESS); } |