task: move Scheduler into a trait, define static-sized scheduler implementation, expose as a system task runner in platform

This commit is contained in:
2024-12-02 19:32:18 +01:00
parent 132d7c0a33
commit f789f6ded9
4 changed files with 41 additions and 31 deletions

View File

@@ -10,7 +10,7 @@ mod mappings;
mod buffers;
use crate::platform::{DefaultBoard, Board};
use crate::task::{Task, Scheduler};
use crate::task::{FixedSizeScheduler, Scheduler};
use crate::render::{Surfaces, Renderer};
use crate::geometry::Rectangle;
@@ -26,20 +26,17 @@ fn main() {
log::info!("Surface implementation: {}", core::any::type_name_of_val(&output));
log::info!("Creating animations");
let mut tasks: Vec<Box<dyn Task + 'static>> = vec![
let mut animations = FixedSizeScheduler::new([
Box::new(animations::IdleTask::new(&mut surfaces)),
Box::new(animations::TestPattern::new(surfaces.new_surface(&Rectangle::everything()).unwrap())),
];
tasks.append(&mut board.system_tasks());
tasks.push(Box::new(Renderer::new(output, surfaces)));
let mut runner = Scheduler::new(tasks);
log::info!("Runner ready: {:?}", runner);
let mut renderer = FixedSizeScheduler::new([Box::new(Renderer::new(output, surfaces))]);
log::info!("Ready to rock and roll");
loop {
runner.tick();
animations.tick();
system.tick();
renderer.tick();
}
}