MCPcopy Create free account
hub / github.com/aws/clock-bound / new

Method new

clock-bound/src/daemon/clock_sync_algorithm/ff/ntp.rs:46–64  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 ///

Callers

nothing calls this directly

Calls 2

newFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected