mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-22 14:53:03 +00:00
embassy-macros: Use defmt::unwrap!
when spawning embassy::main
But only when `defmt` feature is enabled.
This commit is contained in:
parent
40e7176e13
commit
a3b56a3764
@ -364,7 +364,7 @@ pub fn main(args: TokenStream, item: TokenStream) -> TokenStream {
|
|||||||
#chip_setup
|
#chip_setup
|
||||||
|
|
||||||
executor.run(|spawner| {
|
executor.run(|spawner| {
|
||||||
spawner.spawn(__embassy_main(spawner, p)).unwrap();
|
spawner.must_spawn(__embassy_main(spawner, p));
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,14 @@ impl Spawner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Used by the `embassy_macros::main!` macro to throw an error when spawn
|
||||||
|
/// fails. This is here to allow conditional use of `defmt::unwrap!`
|
||||||
|
/// without introducing a `defmt` feature in the `embassy_macros` package,
|
||||||
|
/// which would require use of `-Z namespaced-features`.
|
||||||
|
pub fn must_spawn<F>(&self, token: SpawnToken<F>) -> () {
|
||||||
|
unwrap!(self.spawn(token));
|
||||||
|
}
|
||||||
|
|
||||||
/// Convert this Spawner to a SendSpawner. This allows you to send the
|
/// Convert this Spawner to a SendSpawner. This allows you to send the
|
||||||
/// spawner to other threads, but the spawner loses the ability to spawn
|
/// spawner to other threads, but the spawner loses the ability to spawn
|
||||||
/// non-Send tasks.
|
/// non-Send tasks.
|
||||||
|
Loading…
Reference in New Issue
Block a user