← 返回卡片

原书出处

Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)

05 Chapter 5. Coroutines 在单线程驱动多个等待

First Edition · 核验版本的摘录快照 · 导入于 2026-11-25T07:07:54.320Z

for our SleepCoroutine with the following code:

impl Future for SleepCoroutine { type Output = (); fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { match Pin::new(&mut self).resume(()) { CoroutineState::Complete(_) => Poll::Ready(()), CoroutineState::Yielded(_) => { cx.waker().wake_by_ref(); Poll::Pending }, } } }

To recap, this example demonstrates that coroutines

此预览只包含定位所需的摘录和上下文。

原书定位详情

来源:a19c7933-4eda-4176-aebd-30fe7e1ad292

正文位置:extracted/Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)/_epub-src/OEBPS/ch05.html#id36

EPUB SHA-256:109ff0224da54833b0d49c82502e850845274913fe34a7168dcf36a9c075b4e0