From dff03ecfc74d6af716637888338ebfa99ab7a027 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Wed, 2 Jun 2021 01:30:07 +0200 Subject: Move examples to a subdirectory --- examples/nrf/src/bin/executor_fairness_test.rs | 47 ++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 examples/nrf/src/bin/executor_fairness_test.rs (limited to 'examples/nrf/src/bin/executor_fairness_test.rs') diff --git a/examples/nrf/src/bin/executor_fairness_test.rs b/examples/nrf/src/bin/executor_fairness_test.rs new file mode 100644 index 000000000..797be4335 --- /dev/null +++ b/examples/nrf/src/bin/executor_fairness_test.rs @@ -0,0 +1,47 @@ +#![no_std] +#![no_main] +#![feature(min_type_alias_impl_trait)] +#![feature(impl_trait_in_bindings)] +#![feature(type_alias_impl_trait)] +#![allow(incomplete_features)] + +#[path = "../example_common.rs"] +mod example_common; +use example_common::*; + +use core::task::Poll; +use defmt::panic; +use embassy::executor::Spawner; +use embassy::time::{Duration, Instant, Timer}; +use embassy_nrf::{interrupt, Peripherals}; + +#[embassy::task] +async fn run1() { + loop { + info!("DING DONG"); + Timer::after(Duration::from_ticks(16000)).await; + } +} + +#[embassy::task] +async fn run2() { + loop { + Timer::at(Instant::from_ticks(0)).await; + } +} + +#[embassy::task] +async fn run3() { + futures::future::poll_fn(|cx| { + cx.waker().wake_by_ref(); + Poll::<()>::Pending + }) + .await; +} + +#[embassy::main] +async fn main(spawner: Spawner, _p: Peripherals) { + unwrap!(spawner.spawn(run1())); + unwrap!(spawner.spawn(run2())); + unwrap!(spawner.spawn(run3())); +} -- cgit