mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 14:27:49 +00:00
26 lines
474 B
Rust
26 lines
474 B
Rust
use alloc::boxed::Box;
|
|
use core::{
|
|
future::Future,
|
|
pin::Pin,
|
|
task::{Context, Poll},
|
|
};
|
|
|
|
pub mod keyboard;
|
|
pub mod simple_executor;
|
|
|
|
pub struct Task {
|
|
future: Pin<Box<dyn Future<Output = ()>>>,
|
|
}
|
|
|
|
impl Task {
|
|
pub fn new(future: impl Future<Output = ()> + 'static) -> Task {
|
|
Task {
|
|
future: Box::pin(future),
|
|
}
|
|
}
|
|
|
|
fn poll(&mut self, context: &mut Context) -> Poll<()> {
|
|
self.future.as_mut().poll(context)
|
|
}
|
|
}
|