priority/
priority.rs

1use native_executor::{Priority, spawn, spawn_with_priority, timer::Timer};
2use std::time::Duration;
3
4fn main() {
5    // Spawn a default priority task
6    spawn(async {
7        println!("Default priority task started");
8        Timer::after_secs(1).await;
9        println!("Default priority task completed");
10    })
11    .detach();
12
13    // Spawn a background priority task
14    spawn_with_priority(
15        async {
16            println!("Background priority task started");
17            Timer::after_secs(1).await;
18            println!("Background priority task completed");
19        },
20        Priority::Background,
21    )
22    .detach();
23
24    // Keep the main thread alive
25    std::thread::sleep(Duration::from_secs(2));
26}