Skip to main content

sparreal_kernel/os/async/
mod.rs

1//! Sparreal OS Async Runtime
2//!
3//! Single CPU async executor based on embassy design, providing tokio-like API experience.
4//!
5//! # Features
6//!
7//! - Single CPU async task execution
8//! - Wake task priority scheduling
9//! - Timeout task priority promotion (default 1 second)
10//! - Interrupt safe (using IrqSpinlock)
11//! - Dynamic memory allocation (alloc)
12//!
13//! # Usage Examples
14//!
15//! ```rust
16//! use sparreal_kernel::os::async::{spawn, block_on, tick};
17//!
18//! // Spawn async task
19//! let handle = spawn(async {
20//!     // Async task code
21//!     println!("Hello from async task!");
22//! });
23//!
24//! // Block until task completes
25//! block_on(async {
26//!     // Your async code
27//! });
28//!
29//! // Manual scheduling (in event loop)
30//! loop {
31//!     tick();  // Process one task scheduling
32//!     // Other main loop logic...
33//! }
34//! ```
35
36pub mod executor;
37pub mod task;
38
39// #[cfg(test)]
40// mod tests;
41
42// Re-export public interfaces
43pub use executor::{SingleCpuExecutor, block_on, has_pending_tasks, spawn, task_count, tick};
44
45pub use task::{TaskHandle, TaskId, TaskState};