rust-kernel
Rustbelt: a hobby x86_64 kernel written in Rust
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | //! Cooperative multitasking with async/await.
//!
//! An `async fn` compiles to a state machine implementing `Future`. Calling
//! `poll` on it runs it until it either finishes (`Poll::Ready`) or has to
//! wait (`Poll::Pending`) -- e.g. for a key press. Before returning Pending,
//! the future hands the `Waker` from its `Context` to whoever will make
//! progress possible (here: the keyboard interrupt). When that happens,
//! `waker.wake()` tells the executor to poll the task again.
//!
//! "Cooperative": a task only gives up the CPU at an `.await`. A task that
//! loops forever without awaiting blocks every other task. (Compare the
//! preemptive threads in `thread.rs`.)
use Box;
use ;
/// A task = a heap-allocated, pinned future with no output.
/// `Pin` because async state machines may contain pointers into themselves,
/// so they must never move in memory once polled.
/// Unique id per task, so wakers can say *which* task to run again.
;
/// A future that returns Pending once (waking itself straight away), then
/// Ready. `yield_now().await` lets other tasks run -- handy for demos/tests.
pub async
|