aboutsummaryrefslogtreecommitdiff
path: root/examples/nrf/src/bin/executor_fairness_test.rs
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2021-06-02 01:30:07 +0200
committerDario Nieuwenhuis <[email protected]>2021-06-02 01:32:19 +0200
commitdff03ecfc74d6af716637888338ebfa99ab7a027 (patch)
treec06bf2b0a2e6657c3427c956dbd27a4e45211aaa /examples/nrf/src/bin/executor_fairness_test.rs
parenta0c5f7137fe0c45b8db0aad2a116aea91e6a93f7 (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.rs47
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"]
9mod example_common;
10use example_common::*;
11
12use core::task::Poll;
13use defmt::panic;
14use embassy::executor::Spawner;
15use embassy::time::{Duration, Instant, Timer};
16use embassy_nrf::{interrupt, Peripherals};
17
18#[embassy::task]
19async fn run1() {
20 loop {
21 info!("DING DONG");
22 Timer::after(Duration::from_ticks(16000)).await;
23 }
24}
25
26#[embassy::task]
27async fn run2() {
28 loop {
29 Timer::at(Instant::from_ticks(0)).await;
30 }
31}
32
33#[embassy::task]
34async 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]
43async fn main(spawner: Spawner, _p: Peripherals) {
44 unwrap!(spawner.spawn(run1()));
45 unwrap!(spawner.spawn(run2()));
46 unwrap!(spawner.spawn(run3()));
47}