-
Notifications
You must be signed in to change notification settings - Fork 62
Closed
Description
tokio has a yield_now()
function that can be used to yield the current task. Because the task will be added to the back of the defer queue, it will be scheduled after other pending tasks (though not guaranteed to drive the driver). Is there any equivalent in Compio? Simply using something like the following will make the task be immediately polled again:
pub async fn yield_now() {
YieldNow(false).await
}
struct YieldNow(bool);
impl Future for YieldNow {
type Output = ();
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
if !self.0 {
self.0 = true;
cx.waker().wake_by_ref();
Poll::Pending
} else {
Poll::Ready(())
}
}
}
inklesspen1rus
Metadata
Metadata
Assignees
Labels
No labels