Initializes the IO task for sampling the PHC source. # Panics - If not called within the `tokio` runtime.
(&mut self, event_sender: async_ring_buffer::Sender<event::Phc>)
| 162 | /// # Panics |
| 163 | /// - If not called within the `tokio` runtime. |
| 164 | pub async fn create_phc(&mut self, event_sender: async_ring_buffer::Sender<event::Phc>) { |
| 165 | info!("Creating PHC source."); |
| 166 | |
| 167 | debug!(?self.phc, "Current PHC source entry status"); |
| 168 | if self.phc.is_none() { |
| 169 | self.phc = { |
| 170 | let (ctrl_sender, ctrl_receiver) = mpsc::channel::<ControlRequest>(1); |
| 171 | let clock_disruption_receiver = self.clock_disruption_channels.sender.subscribe(); |
| 172 | match Phc::construct(event_sender, ctrl_receiver, clock_disruption_receiver).await { |
| 173 | Ok(phc) => Some(Source { |
| 174 | state: SourceState::Initialized(phc), |
| 175 | ctrl_sender, |
| 176 | }), |
| 177 | Err(e) => { |
| 178 | warn!("{}", e); |
| 179 | None |
| 180 | } |
| 181 | } |
| 182 | }; |
| 183 | } |
| 184 | |
| 185 | info!("Source PHC update complete."); |
| 186 | } |
| 187 | |
| 188 | pub fn phc(&self) -> Option<&Phc> { |
| 189 | self.phc.as_ref().and_then(|s| match &s.state { |
no test coverage detected