+ // The active thread yielded. Let's see if there are any timeouts to take care of. We do
+ // this *before* running any other thread, to ensure that timeouts "in the past" fire before
+ // any other thread can take an action. This ensures that for `pthread_cond_timedwait`, "an
+ // error is returned if [...] the absolute time specified by abstime has already been passed
+ // at the time of the call".
+ // <https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cond_timedwait.html>
+ let potential_sleep_time =
+ self.timeout_callbacks.values().map(|info| info.call_time.get_wait_time()).min();
+ if potential_sleep_time == Some(Duration::new(0, 0)) {
+ return Ok(SchedulingAction::ExecuteTimeoutCallback);
+ }
+ // No callbacks scheduled, pick a regular thread to execute.