referrerpolicy=no-referrer-when-downgrade

cpu_time_monitor_loop

Function cpu_time_monitor_loop 

Source
pub fn cpu_time_monitor_loop(
    cpu_time_start: ProcessTime,
    timeout: Duration,
    finished_rx: Receiver<()>,
) -> Option<Duration>
Expand description

Loop that runs in the CPU time monitor thread on prepare and execute jobs. Continuously wakes up and then either blocks for the remaining CPU time, or returns if we exceed the CPU timeout.

Returning Some indicates that we should send a TimedOut error to the host. Will return None if the other thread finishes first, without us timing out.

NOTE: Sending a TimedOut error to the host will cause the worker, whether preparation or execution, to be killed by the host. We do not kill the process here because it would interfere with the proper handling of this error.