This commit is contained in:
Carl Lerche 2023-06-13 11:21:06 -07:00
parent f6f54de2bf
commit e28b1e59ef
No known key found for this signature in database
GPG Key ID: FC5ADF3A4B2E5977

View File

@ -670,6 +670,8 @@ impl Worker {
// We consumed all work in the queues and will start searching for work.
core.stats.end_processing_scheduled_tasks();
core = n!(self.poll_driver(cx, core));
// Try to steal a task from other workers
if let Some(task) = self.steal_work(cx, &mut core) {
core.stats.start_processing_scheduled_tasks();
@ -1045,6 +1047,23 @@ impl Worker {
Ok((maybe_task, core))
}
fn poll_driver(&mut self, cx: &Context, core: Box<Core>) -> NextTaskResult {
// Call `park` with a 0 timeout. This enables the I/O driver, timer, ...
// to run without actually putting the thread to sleep.
if let Some(mut driver) = cx.shared().driver.take() {
println!(" + DRIVER POLL");
driver.park_timeout(&cx.handle.driver, Duration::from_millis(0));
cx.shared().driver.set(driver);
// If there are more I/O events, schedule them.
self.schedule_deferred_with_core(cx, core, || cx.shared().synced.lock())
} else {
Ok((None, core))
}
}
fn park(&mut self, cx: &Context, mut core: Box<Core>) -> NextTaskResult {
if let Some(f) = &cx.shared().config.before_park {
f();