aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/lock-free.no_rs (renamed from examples/lock-free.rs)9
-rw-r--r--examples/lock.rs11
2 files changed, 11 insertions, 9 deletions
diff --git a/examples/lock-free.rs b/examples/lock-free.no_rs
index ea6ff1bf..053307c1 100644
--- a/examples/lock-free.rs
+++ b/examples/lock-free.no_rs
@@ -4,6 +4,7 @@
#![deny(warnings)]
#![no_main]
#![no_std]
+#![feature(type_alias_impl_trait)]
use panic_semihosting as _;
@@ -21,14 +22,14 @@ mod app {
struct Local {}
#[init]
- fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
+ fn init(_: init::Context) -> (Shared, Local) {
foo::spawn().unwrap();
- (Shared { counter: 0 }, Local {}, init::Monotonics())
+ (Shared { counter: 0 }, Local {})
}
#[task(shared = [counter])] // <- same priority
- fn foo(c: foo::Context) {
+ async fn foo(c: foo::Context) {
bar::spawn().unwrap();
*c.shared.counter += 1; // <- no lock API required
@@ -37,7 +38,7 @@ mod app {
}
#[task(shared = [counter])] // <- same priority
- fn bar(c: bar::Context) {
+ async fn bar(c: bar::Context) {
foo::spawn().unwrap();
*c.shared.counter += 1; // <- no lock API required
diff --git a/examples/lock.rs b/examples/lock.rs
index f1a16968..50b6aaae 100644
--- a/examples/lock.rs
+++ b/examples/lock.rs
@@ -4,6 +4,7 @@
#![deny(warnings)]
#![no_main]
#![no_std]
+#![feature(type_alias_impl_trait)]
use panic_semihosting as _;
@@ -20,15 +21,15 @@ mod app {
struct Local {}
#[init]
- fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
+ fn init(_: init::Context) -> (Shared, Local) {
foo::spawn().unwrap();
- (Shared { shared: 0 }, Local {}, init::Monotonics())
+ (Shared { shared: 0 }, Local {})
}
// when omitted priority is assumed to be `1`
#[task(shared = [shared])]
- fn foo(mut c: foo::Context) {
+ async fn foo(mut c: foo::Context) {
hprintln!("A").unwrap();
// the lower priority task requires a critical section to access the data
@@ -53,7 +54,7 @@ mod app {
}
#[task(priority = 2, shared = [shared])]
- fn bar(mut c: bar::Context) {
+ async fn bar(mut c: bar::Context) {
// the higher priority task does still need a critical section
let shared = c.shared.shared.lock(|shared| {
*shared += 1;
@@ -65,7 +66,7 @@ mod app {
}
#[task(priority = 3)]
- fn baz(_: baz::Context) {
+ async fn baz(_: baz::Context) {
hprintln!("C").unwrap();
}
}