simple_task/simple_task.rs
1use native_executor::{spawn, timer::Timer};
2use std::time::Duration;
3
4fn main() {
5 println!("Starting example");
6
7 // Spawn a task with default priority
8 spawn(async {
9 println!("Task started");
10
11 // Wait for 1 second
12 Timer::after_secs(1).await;
13
14 println!("Task completed after 1 second");
15 })
16 .detach();
17
18 // Keep the main thread alive
19 std::thread::sleep(Duration::from_secs(2));
20
21 println!("Example completed");
22}