Polls the time manager to update the timers and emit signals if necessary.
(&mut self, emitter: impl Fn(Signo))
| 167 | /// Polls the time manager to update the timers and emit signals if |
| 168 | /// necessary. |
| 169 | pub fn poll(&mut self, emitter: impl Fn(Signo)) { |
| 170 | let now_ns = monotonic_time_nanos() as usize; |
| 171 | let delta = now_ns - self.last_wall_ns; |
| 172 | match self.state { |
| 173 | TimerState::User => { |
| 174 | self.utime_ns += delta; |
| 175 | self.update_itimer(ITimerType::Virtual, delta, &emitter); |
| 176 | self.update_itimer(ITimerType::Prof, delta, &emitter); |
| 177 | } |
| 178 | TimerState::Kernel => { |
| 179 | self.stime_ns += delta; |
| 180 | self.update_itimer(ITimerType::Prof, delta, &emitter); |
| 181 | } |
| 182 | TimerState::None => {} |
| 183 | } |
| 184 | self.update_itimer(ITimerType::Real, delta, &emitter); |
| 185 | self.last_wall_ns = now_ns; |
| 186 | } |
| 187 | |
| 188 | /// Updates the timer state. |
| 189 | pub fn set_state(&mut self, state: TimerState) { |
no test coverage detected