response_time_analysis/wcet/
multiframe.rs1use super::JobCostModel;
2use crate::time::Service;
3
4#[derive(Debug, Clone)]
8pub struct Multiframe {
9 costs: Vec<Service>,
10}
11
12impl Multiframe {
13 pub fn new(costs: Vec<Service>) -> Self {
16 Multiframe { costs }
17 }
18}
19
20impl JobCostModel for Multiframe {
21 fn job_cost_iter<'a>(&'a self) -> Box<dyn Iterator<Item = Service> + 'a> {
22 Box::new(self.costs.iter().copied().cycle())
23 }
24
25 fn least_wcet(&self, n: usize) -> Service {
26 self.costs
27 .iter()
28 .take(n)
29 .copied()
30 .min()
31 .unwrap_or_else(Service::none)
32 }
33}