Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(YIELD_TO_EXECUTOR_IF_READY_ON_FIRST_POLL): it always yieled #38

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions tokio-epoll-uring/src/system/slots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,9 @@ impl SlotHandle {
NeedToWait,
ShutDown,
}
let mut poll_count = 0;
let inspect_slot_res = poll_fn(|cx| {
poll_count += 1;
let inspect_slot_res = slot.slots_weak.try_upgrade_mut(move |inner| {
let storage = &mut inner.storage;
let slot_storage_ref = &mut storage[slot.idx];
Expand Down Expand Up @@ -538,13 +540,14 @@ impl SlotHandle {
}
})
.await;
let res: i32;
let was_ready_on_first_poll: bool;
match inspect_slot_res {
InspectSlotResult::AlreadyDone(r) => {
res = r;
was_ready_on_first_poll = true;
}
assert!(poll_count >= 1);
assert!(
!matches!(inspect_slot_res, InspectSlotResult::NeedToWait),
"poll_fn closure returns Pending in that case"
);
problame marked this conversation as resolved.
Show resolved Hide resolved

let res = match inspect_slot_res {
InspectSlotResult::AlreadyDone(r) => r,
InspectSlotResult::NeedToWait => {
unreachable!()
}
Expand All @@ -564,8 +567,7 @@ impl SlotHandle {
}
};

if was_ready_on_first_poll && *crate::env_tunables::YIELD_TO_EXECUTOR_IF_READY_ON_FIRST_POLL
{
if poll_count == 1 && *crate::env_tunables::YIELD_TO_EXECUTOR_IF_READY_ON_FIRST_POLL {
tokio::task::yield_now().await;
}

Expand Down
Loading