diff options
| author | Dario Nieuwenhuis <[email protected]> | 2021-06-02 01:30:07 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2021-06-02 01:32:19 +0200 |
| commit | dff03ecfc74d6af716637888338ebfa99ab7a027 (patch) | |
| tree | c06bf2b0a2e6657c3427c956dbd27a4e45211aaa /examples/nrf/src/bin/executor_fairness_test.rs | |
| parent | a0c5f7137fe0c45b8db0aad2a116aea91e6a93f7 (diff) | |
Move examples to a subdirectory
Diffstat (limited to 'examples/nrf/src/bin/executor_fairness_test.rs')
| -rw-r--r-- | examples/nrf/src/bin/executor_fairness_test.rs | 47 |
1 files changed, 47 insertions, 0 deletions
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 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(min_type_alias_impl_trait)] | ||
| 4 | #![feature(impl_trait_in_bindings)] | ||
| 5 | #![feature(type_alias_impl_trait)] | ||
| 6 | #![allow(incomplete_features)] | ||
| 7 | |||
| 8 | #[path = "../example_common.rs"] | ||
| 9 | mod example_common; | ||
| 10 | use example_common::*; | ||
| 11 | |||
| 12 | use core::task::Poll; | ||
| 13 | use defmt::panic; | ||
| 14 | use embassy::executor::Spawner; | ||
| 15 | use embassy::time::{Duration, Instant, Timer}; | ||
| 16 | use embassy_nrf::{interrupt, Peripherals}; | ||
| 17 | |||
| 18 | #[embassy::task] | ||
| 19 | async fn run1() { | ||
| 20 | loop { | ||
| 21 | info!("DING DONG"); | ||
| 22 | Timer::after(Duration::from_ticks(16000)).await; | ||
| 23 | } | ||
| 24 | } | ||
| 25 | |||
| 26 | #[embassy::task] | ||
| 27 | async fn run2() { | ||
| 28 | loop { | ||
| 29 | Timer::at(Instant::from_ticks(0)).await; | ||
| 30 | } | ||
| 31 | } | ||
| 32 | |||
| 33 | #[embassy::task] | ||
| 34 | async fn run3() { | ||
| 35 | futures::future::poll_fn(|cx| { | ||
| 36 | cx.waker().wake_by_ref(); | ||
| 37 | Poll::<()>::Pending | ||
| 38 | }) | ||
| 39 | .await; | ||
| 40 | } | ||
| 41 | |||
| 42 | #[embassy::main] | ||
| 43 | async fn main(spawner: Spawner, _p: Peripherals) { | ||
| 44 | unwrap!(spawner.spawn(run1())); | ||
| 45 | unwrap!(spawner.spawn(run2())); | ||
| 46 | unwrap!(spawner.spawn(run3())); | ||
| 47 | } | ||
