<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh">
    <title>bigfish的网络博客 - 协程</title>
    <subtitle>记录技术和生活</subtitle>
    <link rel="self" type="application/atom+xml" href="https://blog.laofu.online/tags/xie-cheng/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://blog.laofu.online"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2026-10-07T22:15:22+08:00</updated>
    <id>https://blog.laofu.online/tags/xie-cheng/atom.xml</id>
    <entry xml:lang="zh">
        <title>Rust 无栈协程如何暂停和恢复？从 Future 与 poll 走完一次 HTTP 请求</title>
        <published>2026-10-07T22:15:22+08:00</published>
        <updated>2026-10-07T22:15:22+08:00</updated>
        
        <author>
          <name>bigfish</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://blog.laofu.online/blog/rust-stackless-future-poll-waker/"/>
        <id>https://blog.laofu.online/blog/rust-stackless-future-poll-waker/</id>
        
        <summary type="html">&lt;p&gt;调用一个 async 函数，为什么 HTTP 请求还没发出去？函数等网络时，线程去了哪里？调用栈都退出了，变量又怎样留到下一次执行？&lt;/p&gt;
&lt;p&gt;Rust 的无栈协程要解决的就是这组问题：开发者按顺序写代码，编译器把跨暂停的计算变成 Future 状态机；执行器或父 Future 调用 poll，让它获得执行机会。暂时不能继续时返回 Pending，之后按保存的状态推进。&lt;/p&gt;
&lt;p&gt;“无栈”不代表不使用线程栈。每次执行 poll 仍有普通函数调用栈，只是不为每份等待中的计算保留一份专属协程栈。下面沿一次 HTTP 请求，把调用者、状态保存、通知与恢复分别讲清，不要求你先了解 Go 或 Tokio 源码。&lt;/p&gt;</summary>
        
    </entry>
    <entry xml:lang="zh">
        <title>从并发模型的演进看：为什么 Rust 的无栈协程是最优解？</title>
        <published>2026-10-07T15:48:15+08:00</published>
        <updated>2026-10-07T15:48:15+08:00</updated>
        
        <author>
          <name>bigfish</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://blog.laofu.online/blog/thread-goroutine-rust-stackless-design/"/>
        <id>https://blog.laofu.online/blog/thread-goroutine-rust-stackless-design/</id>
        
        <summary type="html">&lt;p&gt;Go 可以在普通调用链深处挂起 goroutine，让线程去执行其他工作。Rust 为什么没有采用同样的方式，却要求显式的 async/await，还引入 Future、Pin 和执行器？&lt;/p&gt;
&lt;p&gt;答案不只是“无栈更省内存”。Rust 要在支持大量等待的同时，保留可组合的抽象，不强制所有程序依赖统一的调度与 I/O 运行时。这组目标，决定了它怎样保存未完成的工作。&lt;/p&gt;
&lt;p&gt;这里的“最优解”指契合 Rust 的设计目标，不是所有负载下的性能冠军。先看线程怎样保存执行现场，再沿 Go 和 Rust 的暂停、恢复过程比较两种选择。&lt;/p&gt;</summary>
        
    </entry>
</feed>
