Skip to content

Commit

Permalink
Remove busy loop tasks (osbook_day16f)
Browse files Browse the repository at this point in the history
  • Loading branch information
gifnksm committed Jun 6, 2021
1 parent 845786b commit b9783b8
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 126 deletions.
28 changes: 0 additions & 28 deletions src/co_task.rs
Expand Up @@ -42,31 +42,3 @@ impl CoTask {
self.future.as_mut().poll(cx)
}
}

struct Yield {
yielded: bool,
}

impl Yield {
fn new() -> Self {
Self { yielded: false }
}
}

impl Future for Yield {
type Output = ();

fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
if !self.yielded {
cx.waker().wake_by_ref();
self.yielded = true;
Poll::Pending
} else {
Poll::Ready(())
}
}
}

pub(crate) async fn yield_now() {
Yield::new().await
}
58 changes: 0 additions & 58 deletions src/counter_window.rs

This file was deleted.

40 changes: 0 additions & 40 deletions src/main.rs
Expand Up @@ -17,7 +17,6 @@ extern crate alloc;

use self::{
co_task::{CoTask, Executor},
counter_window::CounterWindow,
graphics::{Point, Size},
prelude::*,
task::Task,
Expand All @@ -36,7 +35,6 @@ mod acpi;
mod allocator;
mod co_task;
mod console;
mod counter_window;
mod cxx_support;
mod desktop;
mod emergency_console;
Expand Down Expand Up @@ -134,28 +132,6 @@ fn start_window() -> ! {
executor.spawn(CoTask::new(console::handler_task(console_param).unwrap()));
executor.spawn(CoTask::new(layer_task));

executor.spawn(CoTask::new(async {
#[allow(clippy::unwrap_used)]
let timeout = timer::lapic::oneshot(600).unwrap();
println!("Timer interrupt, timeout = {}", timeout.await);
}));
executor.spawn(CoTask::new(async {
let mut i = 0;
#[allow(clippy::unwrap_used)]
let mut timer = timer::lapic::interval(200, 100).unwrap();
while let Some(Ok(timeout)) = timer.next().await {
println!("Timer interrupt, timeout = {}, value = {}", timeout, i);
i += 1;
}
}));

#[allow(clippy::unwrap_used)]
task::spawn(Task::new(
CounterWindow::new("Hello Window".into(), Point::new(300, 100))
.unwrap()
.run()
.unwrap(),
));
#[allow(clippy::unwrap_used)]
task::spawn(Task::new(
TextWindow::new("Text Box test".into(), Point::new(500, 100))
Expand All @@ -164,13 +140,6 @@ fn start_window() -> ! {
.unwrap(),
));
#[allow(clippy::unwrap_used)]
let task_b_id = task::spawn(Task::new(
CounterWindow::new("TaskB Window".into(), Point::new(100, 100))
.unwrap()
.run()
.unwrap(),
));
#[allow(clippy::unwrap_used)]
task::spawn(Task::new(
Terminal::new(
"sabios Terminal".into(),
Expand All @@ -187,15 +156,6 @@ fn start_window() -> ! {
executor.spawn(CoTask::new(async move {
let layer_tx = layer::event_tx();
while let Some(event) = rx.next().await {
match event.ascii {
's' => {
x86_64::instructions::interrupts::without_interrupts(|| task::sleep(task_b_id));
}
'w' => {
x86_64::instructions::interrupts::without_interrupts(|| task::wake(task_b_id));
}
_ => {}
}
#[allow(clippy::unwrap_used)]
layer_tx.keyboard_event(event).await.unwrap();
}
Expand Down

0 comments on commit b9783b8

Please sign in to comment.