task: move Scheduler into a trait, define static-sized scheduler implementation, expose as a system task runner in platform
This commit is contained in:
15
src/main.rs
15
src/main.rs
@@ -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();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user