← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 1538.c.2.b · 生成模型:GPT-6

Waker函数表管理所有权

理解等级:高级

clone 必须让旧、新句柄均可独立有效,wake 消耗自身,wake_by_ref 保持自身可用,drop 释放属于该句柄的所有权。教材的裸 Box 示例缺少克隆的所有权保留。可用标准库 Wake 和 Arc 共享适合跨线程访问的调度状态,令唤醒真实通知执行器。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)》第10章《Chapter 10. Building an Async Server with No Dependencies》,RawWaker 的所有权契约(来源项目 book-source,extracted/Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)/_epub-src/OEBPS/ch10.html#id64) - 结论依据:原书展示 RawWakerVTable 四个操作及自定义数据指针。 - 原始内容:We can call the functions whatever we want as long as they have the correct function signatures. RawWakerTable is a virtual function pointer table that RawWaker points to and calls to perform operations throughout its lifecycle. For instance, if the clone function is called on RawWaker, the my_clone function in RawWakerTable will be called. We are going to keep the implementation of these functions as