aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-macros/src/lib.rs2
-rw-r--r--embassy/src/executor/mod.rs8
2 files changed, 9 insertions, 1 deletions
diff --git a/embassy-macros/src/lib.rs b/embassy-macros/src/lib.rs
index d00baebfe..ddcee0cb1 100644
--- a/embassy-macros/src/lib.rs
+++ b/embassy-macros/src/lib.rs
@@ -364,7 +364,7 @@ pub fn main(args: TokenStream, item: TokenStream) -> TokenStream {
364 #chip_setup 364 #chip_setup
365 365
366 executor.run(|spawner| { 366 executor.run(|spawner| {
367 spawner.spawn(__embassy_main(spawner, p)).unwrap(); 367 spawner.must_spawn(__embassy_main(spawner, p));
368 }) 368 })
369 369
370 } 370 }
diff --git a/embassy/src/executor/mod.rs b/embassy/src/executor/mod.rs
index ee05b6760..f3c877290 100644
--- a/embassy/src/executor/mod.rs
+++ b/embassy/src/executor/mod.rs
@@ -56,6 +56,14 @@ impl Spawner {
56 } 56 }
57 } 57 }
58 58
59 /// Used by the `embassy_macros::main!` macro to throw an error when spawn
60 /// fails. This is here to allow conditional use of `defmt::unwrap!`
61 /// without introducing a `defmt` feature in the `embassy_macros` package,
62 /// which would require use of `-Z namespaced-features`.
63 pub fn must_spawn<F>(&self, token: SpawnToken<F>) -> () {
64 unwrap!(self.spawn(token));
65 }
66
59 /// Convert this Spawner to a SendSpawner. This allows you to send the 67 /// Convert this Spawner to a SendSpawner. This allows you to send the
60 /// spawner to other threads, but the spawner loses the ability to spawn 68 /// spawner to other threads, but the spawner loses the ability to spawn
61 /// non-Send tasks. 69 /// non-Send tasks.