aboutsummaryrefslogtreecommitdiff
path: root/examples/nrf52840/src/bin/executor_fairness_test.rs
diff options
context:
space:
mode:
authorDominik Boehi <[email protected]>2023-01-09 22:29:58 +0100
committerDominik Boehi <[email protected]>2023-01-09 22:30:02 +0100
commit0a27b6cedb52453123190671f294bbd34918e09a (patch)
tree3888e0b352388ace235517ec97c4d3a88fd7fcfa /examples/nrf52840/src/bin/executor_fairness_test.rs
parent401185b1d95a2519ee94e5d5654cc9325fe85eec (diff)
Rename examples/nrf to examples/nrf52840
Diffstat (limited to 'examples/nrf52840/src/bin/executor_fairness_test.rs')
-rw-r--r--examples/nrf52840/src/bin/executor_fairness_test.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/examples/nrf52840/src/bin/executor_fairness_test.rs b/examples/nrf52840/src/bin/executor_fairness_test.rs
new file mode 100644
index 000000000..2a28f2763
--- /dev/null
+++ b/examples/nrf52840/src/bin/executor_fairness_test.rs
@@ -0,0 +1,43 @@
1#![no_std]
2#![no_main]
3#![feature(type_alias_impl_trait)]
4
5use core::future::poll_fn;
6use core::task::Poll;
7
8use defmt::{info, unwrap};
9use embassy_executor::Spawner;
10use embassy_time::{Duration, Instant, Timer};
11use {defmt_rtt as _, panic_probe as _};
12
13#[embassy_executor::task]
14async fn run1() {
15 loop {
16 info!("DING DONG");
17 Timer::after(Duration::from_ticks(16000)).await;
18 }
19}
20
21#[embassy_executor::task]
22async fn run2() {
23 loop {
24 Timer::at(Instant::from_ticks(0)).await;
25 }
26}
27
28#[embassy_executor::task]
29async fn run3() {
30 poll_fn(|cx| {
31 cx.waker().wake_by_ref();
32 Poll::<()>::Pending
33 })
34 .await;
35}
36
37#[embassy_executor::main]
38async fn main(spawner: Spawner) {
39 let _p = embassy_nrf::init(Default::default());
40 unwrap!(spawner.spawn(run1()));
41 unwrap!(spawner.spawn(run2()));
42 unwrap!(spawner.spawn(run3()));
43}