embassy/examples/nrf52840/src/bin/executor_fairness_test.rs

44 lines
859 B
Rust
Raw Normal View History

#![no_std]
#![no_main]
#![feature(type_alias_impl_trait)]
use core::future::poll_fn;
use core::task::Poll;
2022-06-12 22:15:44 +02:00
use defmt::{info, unwrap};
use embassy_executor::Spawner;
use embassy_time::{Instant, Timer};
2022-06-12 22:15:44 +02:00
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::task]
async fn run1() {
loop {
info!("DING DONG");
Timer::after_ticks(16000).await;
}
}
#[embassy_executor::task]
async fn run2() {
loop {
Timer::at(Instant::from_ticks(0)).await;
}
}
#[embassy_executor::task]
async fn run3() {
poll_fn(|cx| {
cx.waker().wake_by_ref();
Poll::<()>::Pending
})
.await;
}
#[embassy_executor::main]
async fn main(spawner: Spawner) {
let _p = embassy_nrf::init(Default::default());
2021-03-29 02:47:10 +02:00
unwrap!(spawner.spawn(run1()));
unwrap!(spawner.spawn(run2()));
unwrap!(spawner.spawn(run3()));
}