response_time_analysis/arrival/
periodic.rs1use super::{divide_with_ceil, ArrivalBound, Sporadic};
2use crate::time::Duration;
3
4#[derive(Copy, Clone, Debug)]
6pub struct Periodic {
7 pub period: Duration,
9}
10
11impl Periodic {
12 pub fn new(period: Duration) -> Periodic {
14 Periodic { period }
15 }
16}
17
18impl ArrivalBound for Periodic {
19 fn number_arrivals(&self, delta: Duration) -> usize {
20 divide_with_ceil(delta, self.period) as usize
21 }
22
23 fn steps_iter<'a>(&'a self) -> Box<dyn Iterator<Item = Duration> + 'a> {
24 Box::new((0..).map(move |j| self.period * j + Duration::from(1)))
25 }
26
27 fn clone_with_jitter(&self, jitter: Duration) -> Box<dyn ArrivalBound> {
28 let mut ab = Box::new(Sporadic::from(*self));
29 ab.jitter = jitter;
30 ab
31 }
32}