response_time_analysis/supply/
mod.rs

1/*! Models of resource supply (e.g., dedicated processors, reservations, etc.)
2
3This module provides the trait [SupplyBound], which models the notion of
4a *supply-bound function* (SBF), as well as common types of supply. */
5
6use auto_impl::auto_impl;
7
8use crate::time::{Duration, Service};
9
10/// Generic interface for models of processor supply.
11#[auto_impl(&, Box, Rc)]
12pub trait SupplyBound {
13    /// Bound the minimum amount of service provided during an
14    /// interval of length `delta`.
15    fn provided_service(&self, delta: Duration) -> Service;
16
17    /// Bound the maximum interval length during which the supply
18    /// provides at least `demand` amount of service.
19    fn service_time(&self, demand: Service) -> Duration {
20        let mut t = Duration::from(demand);
21        loop {
22            let supply = self.provided_service(t);
23            if supply >= demand {
24                return t;
25            }
26            // jump ahead by how much is still missing
27            t += Duration::from(demand - supply);
28        }
29    }
30}
31
32mod constrained;
33mod dedicated;
34mod periodic;
35
36pub use constrained::Constrained;
37pub use dedicated::Dedicated;
38pub use periodic::Periodic;
39
40#[cfg(test)]
41mod tests;