pi-async-runtime-core 0.1.2

与具体执行器和队列实现无关的运行时核心能力
Documentation
use std::{
    future::Future,
    pin::Pin,
    task::{Context, Poll},
};
/// 主动让出一次;须实际await才开始,不保证另一个任务(Task)一定先执行。
pub async fn yield_now() {
    YieldOnce::new().await
}
pub(crate) struct YieldOnce {
    yielded: bool,
}
impl YieldOnce {
    pub(crate) fn new() -> Self {
        Self { yielded: false }
    }
}
impl Future for YieldOnce {
    type Output = ();
    fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {
        yield_once_poll_inner(self, cx)
    }
}
include!("yielding_inner.rs");