From abc8e450f936567ad42cb34b5d2a7941b206aa5d Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Mon, 6 Oct 2025 22:55:38 +0200 Subject: Edition 2024. --- examples/std/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples/std') diff --git a/examples/std/Cargo.toml b/examples/std/Cargo.toml index 449c5ddca..6dc6a353d 100644 --- a/examples/std/Cargo.toml +++ b/examples/std/Cargo.toml @@ -1,5 +1,5 @@ [package] -edition = "2021" +edition = "2024" name = "embassy-std-examples" version = "0.1.0" license = "MIT OR Apache-2.0" -- cgit From 7083411ca255efdfe0ebf9cfba8e889c38630aee Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Fri, 12 Dec 2025 00:42:31 +0100 Subject: examples/std: fix warning. --- examples/std/src/bin/net_ppp.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'examples/std') diff --git a/examples/std/src/bin/net_ppp.rs b/examples/std/src/bin/net_ppp.rs index 82272c798..685dbf3d3 100644 --- a/examples/std/src/bin/net_ppp.rs +++ b/examples/std/src/bin/net_ppp.rs @@ -52,7 +52,7 @@ async fn ppp_task(stack: Stack<'static>, mut runner: Runner<'static>, port: Seri password: b"mypass", }; - runner + let r = runner .run(port, config, |ipv4| { let Some(addr) = ipv4.address else { warn!("PPP did not provide an IP address."); @@ -69,9 +69,10 @@ async fn ppp_task(stack: Stack<'static>, mut runner: Runner<'static>, port: Seri }); stack.set_config_v4(config); }) - .await - .unwrap(); - unreachable!() + .await; + match r { + Err(e) => panic!("{:?}", e), + } } #[embassy_executor::task] -- cgit From b1fe9c6955ff857e3729a0bb4727247e050fb7ae Mon Sep 17 00:00:00 2001 From: Gerhard de Clercq <11624490+Gerharddc@users.noreply.github.com> Date: Fri, 12 Dec 2025 13:04:51 +0000 Subject: Add `run_until` function to std Executor as to support grafeul shutdown. --- examples/std/src/bin/tick_cancel.rs | 47 +++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 examples/std/src/bin/tick_cancel.rs (limited to 'examples/std') diff --git a/examples/std/src/bin/tick_cancel.rs b/examples/std/src/bin/tick_cancel.rs new file mode 100644 index 000000000..54e44790f --- /dev/null +++ b/examples/std/src/bin/tick_cancel.rs @@ -0,0 +1,47 @@ +use std::sync::atomic::{AtomicBool, Ordering}; +use std::thread; +use std::time::Duration; + +use embassy_executor::Executor; +use embassy_time::Timer; +use log::*; +use static_cell::StaticCell; + +#[embassy_executor::task] +async fn run() { + loop { + info!("tick"); + Timer::after_secs(1).await; + } +} + +static DONE: StaticCell = StaticCell::new(); +static EXECUTOR: StaticCell = StaticCell::new(); + +fn main() { + env_logger::builder() + .filter_level(log::LevelFilter::Debug) + .format_timestamp_nanos() + .init(); + + let done = DONE.init(AtomicBool::new(false)); + let done_cb = || done.load(Ordering::Relaxed); + + let server_thread = thread::spawn(move || { + let executor = EXECUTOR.init(Executor::new()); + executor.run_until( + |spawner| { + spawner.spawn(run().unwrap()); + }, + done_cb, + ); + info!("Executor finished"); + }); + + thread::sleep(Duration::from_secs(5)); + + info!("Cancelling executor"); + done.store(true, Ordering::Relaxed); + + server_thread.join().unwrap(); +} -- cgit