diff options
| author | 1-rafael-1 <[email protected]> | 2025-09-15 20:07:18 +0200 |
|---|---|---|
| committer | 1-rafael-1 <[email protected]> | 2025-09-15 20:07:18 +0200 |
| commit | 6bb3d2c0720fa082f27d3cdb70f516058497ec87 (patch) | |
| tree | 5a1e255cff999b00800f203b91a759c720c973e5 /examples/nrf52840/src/bin/self_spawn_current_executor.rs | |
| parent | eb685574601d98c44faed9a3534d056199b46e20 (diff) | |
| parent | 92a6fd2946f2cbb15359290f68aa360953da2ff7 (diff) | |
Merge branch 'main' into rp2040-rtc-alarm
Diffstat (limited to 'examples/nrf52840/src/bin/self_spawn_current_executor.rs')
| -rw-r--r-- | examples/nrf52840/src/bin/self_spawn_current_executor.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/examples/nrf52840/src/bin/self_spawn_current_executor.rs b/examples/nrf52840/src/bin/self_spawn_current_executor.rs index ec9569a64..d93067592 100644 --- a/examples/nrf52840/src/bin/self_spawn_current_executor.rs +++ b/examples/nrf52840/src/bin/self_spawn_current_executor.rs | |||
| @@ -10,12 +10,13 @@ use {defmt_rtt as _, panic_probe as _}; | |||
| 10 | async fn my_task(n: u32) { | 10 | async fn my_task(n: u32) { |
| 11 | Timer::after_secs(1).await; | 11 | Timer::after_secs(1).await; |
| 12 | info!("Spawning self! {}", n); | 12 | info!("Spawning self! {}", n); |
| 13 | unwrap!(Spawner::for_current_executor().await.spawn(my_task(n + 1))); | 13 | let spawner = unsafe { Spawner::for_current_executor().await }; |
| 14 | spawner.spawn(unwrap!(my_task(n + 1))); | ||
| 14 | } | 15 | } |
| 15 | 16 | ||
| 16 | #[embassy_executor::main] | 17 | #[embassy_executor::main] |
| 17 | async fn main(spawner: Spawner) { | 18 | async fn main(spawner: Spawner) { |
| 18 | let _p = embassy_nrf::init(Default::default()); | 19 | let _p = embassy_nrf::init(Default::default()); |
| 19 | info!("Hello World!"); | 20 | info!("Hello World!"); |
| 20 | unwrap!(spawner.spawn(my_task(0))); | 21 | spawner.spawn(unwrap!(my_task(0))); |
| 21 | } | 22 | } |
