Create a new feed forward time synchronization algorithm `local_capacity` should be the number of data-points to span an SKM window. For example, if the source is expected to sample once every second, the `local_capacity` should have a max value of 1024. # Panics Panics if poll duration is zero or greater than or equal to 512 seconds
(poll_period: Duration, max_dispersion: Skew)
| 44 | /// # Panics |
| 45 | /// Panics if poll duration is zero or greater than or equal to 512 seconds |
| 46 | pub fn new(poll_period: Duration, max_dispersion: Skew) -> Self { |
| 47 | assert!(poll_period > Duration::ZERO, "poll period must be positive"); |
| 48 | assert!( |
| 49 | poll_period < event_buffer::Local::<event::Ntp>::SKM_WINDOW / 2, |
| 50 | "Must be able to get at least 2 samples in local buffer" |
| 51 | ); |
| 52 | let local_capacity = |
| 53 | event_buffer::Local::<event::Ntp>::SKM_WINDOW.get() / poll_period.get(); |
| 54 | |
| 55 | // unwrap: input is bound and numerator is never 0 |
| 56 | let local_capacity = NonZeroUsize::new(local_capacity.try_into().unwrap()).unwrap(); |
| 57 | Self { |
| 58 | local: event_buffer::Local::new(local_capacity), |
| 59 | estimate: event_buffer::Estimate::new(), |
| 60 | clock_parameters: None, |
| 61 | uncorrected_clock: None, |
| 62 | max_dispersion, |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | /// Feed an event into this algorithm |
| 67 | /// |